{"record":{"id":"901ccab502f03f9e","repo":"apache/iceberg","slug":"avro-does-not-support-local-timestamp-type-with-pr-901cca","errorCode":null,"errorMessage":"Avro does not support LOCAL TIMESTAMP type with precision: \" + precision + \", it only supports precision less than 6.","messagePattern":"Avro does not support LOCAL 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":500,"sourceCode":"        precision = timestampType.getPrecision();\n        org.apache.avro.LogicalType avroLogicalType;\n        if (legacyTimestampMapping) {\n          if (precision <= 3) {\n            avroLogicalType = LogicalTypes.timestampMillis();\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 3.\");\n          }\n        } else {\n          if (precision <= 3) {\n            avroLogicalType = LogicalTypes.localTimestampMillis();\n          } else if (precision <= 6) {\n            avroLogicalType = LogicalTypes.localTimestampMicros();\n          } else {\n            throw new IllegalArgumentException(\n                \"Avro does not support LOCAL TIMESTAMP type \"\n                    + \"with precision: \"\n                    + precision\n                    + \", 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();","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L482-L518","documentation":"For non-legacy mapping, Flink TIMESTAMP(p) maps to Avro local-timestamp-millis (p<=3) or local-timestamp-micros (p<=6). Precision above 6 (nanoseconds, p=7..9) has no Avro logical-type representation, so IllegalArgumentException is thrown saying only precision less than 6 is supported.","triggerScenarios":"Calling convertToSchema with a TimestampType of precision 7-9 and legacyTimestampMapping=false; nested field conversion through fieldBuilder with a nanosecond-precision TIMESTAMP.","commonSituations":"Flink DDL with TIMESTAMP(9); Iceberg tables with nanosecond timestamps flowing into an Avro-based Flink sink; migrating from Spark/Flink sources that use nanos.","solutions":["Downgrade the column to TIMESTAMP(6) or TIMESTAMP(3) in the DDL so Avro has a matching logical type.","Truncate nanosecond values to microseconds before serialization.","Write via a format that supports nanos (e.g. Iceberg's own writer) instead of the generic Avro converter.","If only legacy mode exists in your version, upgrade the iceberg-flink module that adds local-timestamp-micros support."],"exampleFix":"// before\n`ts` TIMESTAMP(9)\n// after\n`ts` TIMESTAMP(6)","handlingStrategy":"validation","validationCode":"TimestampType ts = (TimestampType) logicalType;\nif (!legacyMapping && ts.getPrecision() > 6) {\n  throw new IllegalArgumentException(\"TIMESTAMP(\" + ts.getPrecision() + \") exceeds Avro local-timestamp-micros; use TIMESTAMP(6) or lower\");\n}","typeGuard":null,"tryCatchPattern":"try { schema = AvroSchemaConverter.convertToSchema(type, false); } catch (IllegalArgumentException e) { /* truncate precision to 6 and rebuild schema */ }","preventionTips":["Cap TIMESTAMP precision at 6 for Avro-backed sinks.","Truncate nanosecond sources (e.g. from Spark/Java time) at ingestion.","Centralize precision checks in a DDL review checklist."],"tags":["flink","avro","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-14T16:17:12.679Z"}