apache/iceberg · error · java.lang.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
TIMESTAMP WITH LOCAL TIME ZONE without legacy mapping supports up to microsecond precision (timestampMicros). Precision 7-9 has no corresponding Avro logical type, so the converter throws IllegalArgumentException rather than truncating.
Solutions
- Declare the column as TIMESTAMP_LTZ(6) or lower
- Cast the column to TIMESTAMP(3)/TIMESTAMP(6) before Avro serialization
- Use a non-Avro format if nanosecond precision is mandatory
Example fix
// before columns: TIMESTAMP_LTZ(9) Schema avro = AvroSchemaConverter.convertToSchema(rowType, "rec", false); // after columns: TIMESTAMP_LTZ(6) Schema avro = AvroSchemaConverter.convertToSchema(rowType, "rec", false);
Defensive patterns
Strategy: validation
Validate before calling
if (localZonedTimestampType.getPrecision() > 6) {
throw new IllegalArgumentException("TIMESTAMP_LTZ precision must be <= 6 for Avro; got " + localZonedTimestampType.getPrecision());
} Prevention
- Use TIMESTAMP_LTZ(3) or TIMESTAMP_LTZ(6) only
- Never accept framework-default TIMESTAMP_LTZ(9) into Avro sinks
- Validate column precisions at job-configuration time, not at runtime
When it happens
Trigger: Calling AvroSchemaConverter.convertToSchema with legacyTimestampMapping=false on a row containing TIMESTAMP_LTZ(7..9).
Common situations: TIMESTAMP_LTZ(9) columns in Flink DDL sent through Avro format sinks; schema precision bumped during evolution without checking Avro limits.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Avro does not support LOCAL TIMESTAMP type with precision
- Avro does not support LOCAL TIMESTAMP type with precision
- Avro does not support TIMESTAMP type with precision
- Avro does not support TIMESTAMP type with precision
- Avro does not support TIMESTAMP type with precision: " +…
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/1185a2238eaefb4d.
Report an issue: GitHub.
Appendix: source
Thrown at flink/v2.1/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: "
+ precisionView on GitHub (pinned to 86d9c8fc54)