{"record":{"id":"1c681ed7fef4c814","repo":"apache/flink","slug":"avro-does-not-support-timestamp-type-with-precisio","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":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java","lineNumber":471,"sourceCode":"                return nullable ? nullableSchema(d) : d;\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":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java#L453-L489","documentation":"Thrown when converting a Flink TIMESTAMP(p) WITHOUT TIME ZONE to an Avro schema while legacy timestamp mapping is enabled. Legacy mapping maps TIMESTAMP to Avro's 'timestamp-millis' logical type only, so precision above 3 (millisecond) cannot be represented; the converter rejects precisions 4-9 instead of silently truncating.","triggerScenarios":"Calling AvroSchemaConverter.convertToSchema(timestampLogicalType, legacyTimestampMapping=true) with TIMESTAMP(6)/TIMESTAMP(9); defining a table with 'avro' or 'avro-confluent-registry' format, a TIMESTAMP(6+) column, and legacy timestamp behaviour enabled (e.g. table.exec.legacy-timestamp-behaviour set for Flink 1.11/1.12 compatibility).","commonSituations":"Migrating jobs from old Flink versions where TIMESTAMP mapped to timestamp-millis; enabling legacy timestamp behaviour globally and then adding micro/nanosecond timestamp columns.","solutions":["Declare the column as TIMESTAMP(3) (or coarser) so it fits timestamp-millis.","Disable legacy timestamp mapping (remove the legacy timestamp behaviour config) so precisions up to 6 map to local-timestamp-millis/micros.","If sub-millisecond precision is required and legacy mapping must stay, store the value as BIGINT microseconds and convert in SQL."],"exampleFix":"-- before\ncol TIMESTAMP(6),\n\n-- after (legacy timestamp mapping enabled)\ncol TIMESTAMP(3),","handlingStrategy":"validation","validationCode":"import org.apache.flink.table.types.logical.TimestampType;\n\nvoid assertLegacyTimestampOk(TimestampType t) {\n    if (t.getPrecision() > 3) {\n        throw new IllegalArgumentException(\n            \"TIMESTAMP(\" + t.getPrecision() + \") unsupported under legacy Avro mapping; use <= 3\");\n    }\n}","typeGuard":"boolean fitsLegacyAvro(TimestampType t) { return t.getPrecision() <= 3; }","tryCatchPattern":null,"preventionTips":["Prefer disabling legacy timestamp behaviour unless Flink <=1.11 compatibility is mandatory.","Audit DDL for bare TIMESTAMP (defaults to precision 9) before attaching avro formats.","Standardize on TIMESTAMP(3) or TIMESTAMP(6) for all Avro-backed tables."],"tags":["avro","timestamp","precision","flink","schema-conversion"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}