{"record":{"id":"237e1d322cfef1c8","repo":"apache/iceberg","slug":"avro-does-not-support-local-timestamp-type-with-pr","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: (.+?), it only supports precision less than 6\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/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/v1.20/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L482-L518","documentation":"When converting a Flink TIMESTAMP (TIMESTAMP_WITHOUT_TIME_ZONE) to Avro with legacyTimestampMapping=false, precision <= 3 maps to localTimestampMillis and <= 6 to localTimestampMicros; anything higher (7-9) has no Avro local-timestamp logical type, so IllegalArgumentException \"...it only supports precision less than 6\" is thrown.","triggerScenarios":"AvroSchemaConverter.convertToSchema(LogicalType, boolean) — directly or via nested fieldBuilder — with TimestampType precision > 6 and legacyTimestampMapping=false, e.g. TIMESTAMP(9).","commonSituations":"Flink defaults TIMESTAMP to precision 6 in some paths; nanosecond-precision columns (TIMESTAMP(9)) declared in DDL; automatic inference assigning high precision from source connectors.","solutions":["Reduce the column precision to TIMESTAMP(6) or lower in the Flink DDL/schema.","Cast in the pipeline: CAST(ts AS TIMESTAMP(6)) before conversion.","If nanosecond fidelity is required, store as a different type (e.g. BIGINT epoch nanos) since Avro logical types max at micros.","Note: unlike the legacy path, non-legacy mapping supports up to precision 6 — check which mapping mode is active."],"exampleFix":"// before\nCREATE TABLE t (ts TIMESTAMP(9)) ...; // conversion throws\n// after\nCREATE TABLE t (ts TIMESTAMP(6)) ...; // maps to localTimestampMicros","handlingStrategy":"validation","validationCode":"TimestampType ts = (TimestampType) logicalType;\nif (!legacyMapping && ts.getPrecision() > 6) {\n  throw new IllegalStateException(\"TIMESTAMP(\" + ts.getPrecision() + \") exceeds Avro micros limit; use <= 6\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  Schema s = AvroSchemaConverter.convertToSchema(timestampType, false);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"LOCAL TIMESTAMP\") && e.getMessage().contains(\"less than 6\")) {\n    s = AvroSchemaConverter.convertToSchema(new TimestampType(6), false);\n  } else throw e;\n}","preventionTips":["Cap timestamp precision at 6 in DDL; Avro has no nanosecond logical types.","CAST TIMESTAMP(7-9) columns to TIMESTAMP(6) in the job graph.","If nanos matter, encode as BIGINT epoch nanos instead."],"tags":["avro","flink","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"}