{"record":{"id":"1185a2238eaefb4d","repo":"apache/iceberg","slug":"avro-does-not-support-timestamp-type-with-precisio-1185a2","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: (.+?), it only supports precision less than 6\\.","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/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.1/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L504-L540","documentation":"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.","triggerScenarios":"Calling AvroSchemaConverter.convertToSchema with legacyTimestampMapping=false on a row containing TIMESTAMP_LTZ(7..9).","commonSituations":"TIMESTAMP_LTZ(9) columns in Flink DDL sent through Avro format sinks; schema precision bumped during evolution without checking Avro limits.","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"],"exampleFix":"// before\ncolumns: TIMESTAMP_LTZ(9)\nSchema avro = AvroSchemaConverter.convertToSchema(rowType, \"rec\", false);\n// after\ncolumns: TIMESTAMP_LTZ(6)\nSchema avro = AvroSchemaConverter.convertToSchema(rowType, \"rec\", false);","handlingStrategy":"validation","validationCode":"if (localZonedTimestampType.getPrecision() > 6) {\n  throw new IllegalArgumentException(\"TIMESTAMP_LTZ precision must be <= 6 for Avro; got \" + localZonedTimestampType.getPrecision());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["avro","flink","timestamp-precision"],"backgroundTag":"value-out-of-range","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"}