{"record":{"id":"3da5e244e146815e","repo":"apache/flink","slug":"avro-does-not-support-local-timestamp-type-with-pr","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":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java","lineNumber":483,"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":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java#L465-L501","documentation":"Thrown when converting TIMESTAMP(p) WITHOUT TIME ZONE to an Avro schema with the modern (non-legacy) mapping and precision above 6. Avro logical types only support local-timestamp-millis (p<=3) and local-timestamp-micros (p<=6); nanosecond precision (7-9) has no Avro representation, so the converter refuses it.","triggerScenarios":"convertToSchema on a TIMESTAMP(7)/TIMESTAMP(8)/TIMESTAMP(9) type; a CREATE TABLE ... WITH ('format'='avro'/'avro-confluent-registry') sink containing a TIMESTAMP(9) column (9 is Flink's default precision for TIMESTAMP).","commonSituations":"Using plain 'TIMESTAMP' in DDL — Flink defaults it to TIMESTAMP(9), which is too precise for Avro; CDC or IoT pipelines that specify nanosecond event-time columns.","solutions":["Explicitly declare TIMESTAMP(3) or TIMESTAMP(6) for columns written to Avro format.","If nanoseconds must be preserved, store as BIGINT and reinterpret downstream."],"exampleFix":"-- before (TIMESTAMP defaults to precision 9)\nevent_time TIMESTAMP,\n\n-- after\nevent_time TIMESTAMP(6),","handlingStrategy":"validation","validationCode":"import org.apache.flink.table.types.logical.TimestampType;\n\nboolean avroConvertible(TimestampType t) { return t.getPrecision() <= 6; }","typeGuard":"boolean fitsAvro(TimestampType t) { return t.getPrecision() <= 6; }","tryCatchPattern":null,"preventionTips":["Always declare an explicit precision for TIMESTAMP columns (TIMESTAMP(3)/TIMESTAMP(6)).","Add a DDL lint step in CI that rejects TIMESTAMP precision > 6 on tables using avro formats."],"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"}