{"record":{"id":"4261d43bae1ab726","repo":"apache/iceberg","slug":"avro-does-not-support-local-timestamp-type-with-pr-4261d4","errorCode":null,"errorMessage":"Avro does not support LOCAL TIMESTAMP type with precision: %s, it only supports precision less than 6.","messagePattern":"Avro does not support LOCAL TIMESTAMP type with precision: (.+?), it only supports precision less than 6\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/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.3/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L482-L518","documentation":"Thrown when converting a Flink TIMESTAMP (without time zone) to an Avro schema with legacyTimestampMapping=false and precision greater than 6. Avro supports localTimestampMillis and localTimestampMicros, so TIMESTAMP(7)-TIMESTAMP(9) cannot be represented. Avro simply has no nanosecond logical type.","triggerScenarios":"Calling AvroSchemaConverter.convertToSchema with a TimestampType of precision 7, 8, or 9 and legacyTimestampMapping=false.","commonSituations":"Flink tables created with TIMESTAMP(9) (default high precision in some connectors) being written to Avro-based sinks (files, Kafka with Avro encoding).","solutions":["Cast the column to TIMESTAMP(6) or lower before writing.","If nanosecond fidelity is required, switch to a format supporting it (e.g. Parquet) instead of Avro.","Adjust the table schema or DDL to define the column as TIMESTAMP(3/6).","Truncate the value at the source (e.g. CAST(ts AS TIMESTAMP(6)))."],"exampleFix":"// before\n// column defined as TIMESTAMP(9)\n// after\n// Flink DDL: `ts` TIMESTAMP(6)  -- fits localTimestampMicros","handlingStrategy":"validation","validationCode":"if (logicalType instanceof TimestampType && ((TimestampType) logicalType).getPrecision() > 6) { throw new IllegalArgumentException(\"Cast TIMESTAMP(p) to p<=6 before Avro serialization\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap TIMESTAMP precision at 6 when the sink is Avro.","Truncate at ingestion rather than at write time.","Switch to Parquet if nanosecond timestamps are a hard requirement.","Check upstream connectors' default precisions — some default to 9."],"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-23T08:17:48.524Z"}