apache/iceberg · error · IllegalArgumentException

Avro does not support TIMESTAMP type with precision: " +…

Error message

Avro does not support TIMESTAMP type with precision: " + precision + ", it only supports precision less than 6.

What it means

Iceberg's Avro schema converter maps Flink TIMESTAMP/TIMESTAMP_LTZ types to Avro logical types (timestamp-millis for precision <=3, timestamp-micros for precision <=6). Avro cannot represent higher precision, so convertToSchema throws IllegalArgumentException. The message says 'less than 6' but the code actually allows precision <=6; only precision >6 triggers it.

Solutions

  1. Declare the timestamp column with precision <= 6, e.g. TIMESTAMP(6) or TIMESTAMP_LTZ(3), in the Flink DDL/table schema.
  2. Cast the timestamp column to TIMESTAMP(6) (or lower) before it reaches the Avro converter (e.g. in the query or via schema evolution).
  3. If nanosecond precision is truly required, use a format/path that supports it (not the Avro-based converter) or store as a different type.

Example fix

// before
CREATE TABLE t (ts TIMESTAMP(9)) ...;
// after
CREATE TABLE t (ts TIMESTAMP(6)) ...;
Defensive patterns

Strategy: validation

Validate before calling

if (type instanceof TimestampType) {
  Preconditions.checkArgument(((TimestampType) type).getPrecision() <= 6,
      "Avro supports TIMESTAMP precision <= 6, got " + ((TimestampType) type).getPrecision());
} else if (type instanceof LocalZonedTimestampType) {
  Preconditions.checkArgument(((LocalZonedTimestampType) type).getPrecision() <= 6,
      "Avro supports TIMESTAMP_LTZ precision <= 6, got " + ((LocalZonedTimestampType) type).getPrecision());
}

Type guard

boolean isAvroCompatible(LogicalType t) {
  return (t instanceof TimestampType ts && ts.getPrecision() <= 6)
      || (t instanceof LocalZonedTimestampType tsz && tsz.getPrecision() <= 6);
}

Try / catch

try {
  Schema s = AvroSchemaConverter.convertToSchema(logicalType, rowName);
} catch (IllegalArgumentException e) {
  // fall back to TIMESTAMP(6) or abort with a clear config error
}

Prevention

When it happens

Trigger: Calling AvroSchemaConverter.convertToSchema with a Flink TimestampType or LocalZonedTimestampType whose precision is greater than 6 (directly or via fieldBuilder when converting a RowType containing such a column).

Common situations: Flink DDL like TIMESTAMP(9) or TIMESTAMP_LTZ(9) (the default precision in some connectors/UDFs), or tables created from engines that default to nanosecond precision, being serialized through the Avro-based Flink state/serializer path.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/811c1baf34ec9411. Report an issue: GitHub.

Appendix: source

Thrown at flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java:522

                    + ", it only supports precision less than 6.");
          }
        }
        Schema timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());
        return nullable ? nullableSchema(timestamp) : timestamp;
      case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
        if (legacyTimestampMapping) {
          throw new UnsupportedOperationException(
              "Unsupported to derive Schema for type: " + logicalType);
        } else {
          final LocalZonedTimestampType localZonedTimestampType =
              (LocalZonedTimestampType) logicalType;
          precision = localZonedTimestampType.getPrecision();
          if (precision <= 3) {
            avroLogicalType = LogicalTypes.timestampMillis();
          } else if (precision <= 6) {
            avroLogicalType = LogicalTypes.timestampMicros();
          } else {
            throw new IllegalArgumentException(
                "Avro does not support TIMESTAMP type "
                    + "with precision: "
                    + precision
                    + ", it only supports precision less than 6.");
          }
          timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());
          return nullable ? nullableSchema(timestamp) : timestamp;
        }
      case DATE:
        // use int to represents Date
        Schema date = LogicalTypes.date().addToSchema(SchemaBuilder.builder().intType());
        return nullable ? nullableSchema(date) : date;
      case TIME_WITHOUT_TIME_ZONE:
        precision = ((TimeType) logicalType).getPrecision();
        if (precision > 3) {
          throw new IllegalArgumentException(
              "Avro does not support TIME type with precision: "
                  + precision

View on GitHub (pinned to 86d9c8fc54)