{"record":{"id":"3f9fc4dbc816dd53","repo":"apache/iceberg","slug":"avro-does-not-support-timestamp-type-with-precisio-3f9fc4","errorCode":null,"errorMessage":"Avro does not support TIMESTAMP type with precision: %s, it only supports precision less than 3.","messagePattern":"Avro does not support TIMESTAMP type with precision: (.+?), it only supports precision less than 3\\.","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":488,"sourceCode":"        return nullable ? nullableSchema(doubleSchema) : doubleSchema;\n      case CHAR:\n      case VARCHAR:\n        Schema str = SchemaBuilder.builder().stringType();\n        return nullable ? nullableSchema(str) : str;\n      case BINARY:\n      case VARBINARY:\n        Schema binary = SchemaBuilder.builder().bytesType();\n        return nullable ? nullableSchema(binary) : binary;\n      case TIMESTAMP_WITHOUT_TIME_ZONE:\n        // use long to represents Timestamp\n        final TimestampType timestampType = (TimestampType) logicalType;\n        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        }","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L470-L506","documentation":"Thrown when converting a Flink TIMESTAMP (without time zone) logical type to an Avro schema with legacyTimestampMapping=true and precision greater than 3. Avro's legacy mapping only offers timestampMillis, so precisions above 3 (e.g. TIMESTAMP(6)) cannot be represented. A higher precision requires the non-legacy mapping, which supports micros.","triggerScenarios":"Calling AvroSchemaConverter.convertToSchema(LogicalType, boolean) (directly or via fieldBuilder) with a TimestampType whose precision is 4-9 while legacyTimestampMapping is true.","commonSituations":"Tables defined with TIMESTAMP(6) or TIMESTAMP(9) being written to Avro with legacy timestamp mapping enabled (often a leftover config from older Flink versions).","solutions":["Disable legacy timestamp mapping (legacyTimestampMapping=false) so micros are used.","Or cast the column to TIMESTAMP(3) to fit timestampMillis.","Update table/connector config to remove the legacy-mapping flag.","Align source schema precision with the sink before writing."],"exampleFix":"// before\nSchema s = AvroSchemaConverter.convertToSchema(timestampType, true); // legacy, precision 6\n// after\nSchema s = AvroSchemaConverter.convertToSchema(timestampType, false); // localTimestampMicros supported","handlingStrategy":"validation","validationCode":"if (logicalType instanceof TimestampType && ((TimestampType) logicalType).getPrecision() > 3 && legacyTimestampMapping) { /* cast column to TIMESTAMP(3) or disable legacy mapping */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Disable legacy timestamp mapping in new pipelines.","Define timestamp columns as precision 3 or 6 up front.","Document precision limits of Avro logical types for the team.","Validate schema precision against the sink format during DDL review."],"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"}