{"record":{"id":"811c1baf34ec9411","repo":"apache/iceberg","slug":"avro-does-not-support-timestamp-type-with-precisio-811c1b","errorCode":null,"errorMessage":"Avro does not support TIMESTAMP type with precision: \" + precision + \", it only supports precision less than 6.","messagePattern":"Avro does not support TIMESTAMP type with precision: \" \\+ precision \\+ \", it only supports precision less than 6\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java","lineNumber":522,"sourceCode":"                    + \", it only supports precision less than 6.\");\n          }\n        }\n        Schema timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());\n        return nullable ? nullableSchema(timestamp) : timestamp;\n      case TIMESTAMP_WITH_LOCAL_TIME_ZONE:\n        if (legacyTimestampMapping) {\n          throw new UnsupportedOperationException(\n              \"Unsupported to derive Schema for type: \" + logicalType);\n        } else {\n          final LocalZonedTimestampType localZonedTimestampType =\n              (LocalZonedTimestampType) logicalType;\n          precision = localZonedTimestampType.getPrecision();\n          if (precision <= 3) {\n            avroLogicalType = LogicalTypes.timestampMillis();\n          } else if (precision <= 6) {\n            avroLogicalType = LogicalTypes.timestampMicros();\n          } else {\n            throw new IllegalArgumentException(\n                \"Avro does not support TIMESTAMP type \"\n                    + \"with precision: \"\n                    + precision\n                    + \", it only supports precision less than 6.\");\n          }\n          timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());\n          return nullable ? nullableSchema(timestamp) : timestamp;\n        }\n      case DATE:\n        // use int to represents Date\n        Schema date = LogicalTypes.date().addToSchema(SchemaBuilder.builder().intType());\n        return nullable ? nullableSchema(date) : date;\n      case TIME_WITHOUT_TIME_ZONE:\n        precision = ((TimeType) logicalType).getPrecision();\n        if (precision > 3) {\n          throw new IllegalArgumentException(\n              \"Avro does not support TIME type with precision: \"\n                  + precision","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L504-L540","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Declare the timestamp column with precision <= 6, e.g. TIMESTAMP(6) or TIMESTAMP_LTZ(3), in the Flink DDL/table schema.","Cast the timestamp column to TIMESTAMP(6) (or lower) before it reaches the Avro converter (e.g. in the query or via schema evolution).","If nanosecond precision is truly required, use a format/path that supports it (not the Avro-based converter) or store as a different type."],"exampleFix":"// before\nCREATE TABLE t (ts TIMESTAMP(9)) ...;\n// after\nCREATE TABLE t (ts TIMESTAMP(6)) ...;","handlingStrategy":"validation","validationCode":"if (type instanceof TimestampType) {\n  Preconditions.checkArgument(((TimestampType) type).getPrecision() <= 6,\n      \"Avro supports TIMESTAMP precision <= 6, got \" + ((TimestampType) type).getPrecision());\n} else if (type instanceof LocalZonedTimestampType) {\n  Preconditions.checkArgument(((LocalZonedTimestampType) type).getPrecision() <= 6,\n      \"Avro supports TIMESTAMP_LTZ precision <= 6, got \" + ((LocalZonedTimestampType) type).getPrecision());\n}","typeGuard":"boolean isAvroCompatible(LogicalType t) {\n  return (t instanceof TimestampType ts && ts.getPrecision() <= 6)\n      || (t instanceof LocalZonedTimestampType tsz && tsz.getPrecision() <= 6);\n}","tryCatchPattern":"try {\n  Schema s = AvroSchemaConverter.convertToSchema(logicalType, rowName);\n} catch (IllegalArgumentException e) {\n  // fall back to TIMESTAMP(6) or abort with a clear config error\n}","preventionTips":["Always declare timestamp columns with explicit precision <= 6 in DDL","Audit UDF/connector output types for TIMESTAMP(9) defaults","Validate table schemas against Avro compatibility before deploying the job"],"tags":["avro","flink","schema-conversion","timestamp-precision"],"backgroundTag":"unsupported-dtype","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}