{"record":{"id":"788eba0ace013425","repo":"apache/iceberg","slug":"avro-does-not-support-timestamp-type-with-precisio-788eba","errorCode":null,"errorMessage":"Avro does not support TIMESTAMP type with precision: \" + precision + \", it only supports precision less than 3.","messagePattern":"Avro does not support TIMESTAMP type with precision: \" \\+ precision \\+ \", it only supports precision less than 3\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/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.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L470-L506","documentation":"When converting a Flink TIMESTAMP(p) logical type to an Avro schema (convertToSchema), legacy timestamp mapping only supports timestamp-millis, i.e. precision <= 3. Higher precision (micros/nanos) has no legacy Avro representation, so IllegalArgumentException is thrown stating Avro only supports precision less than (or equal to) 3 in this mode.","triggerScenarios":"Calling AvroSchemaConverter.convertToSchema with a TimestampType whose precision is > 3 while legacyTimestampMapping=true (the legacy path uses LogicalTypes.timestampMillis).","commonSituations":"See trigger scenarios.","solutions":["Set legacyTimestampMapping=false so precision<=6 maps to localTimestampMicros and 9 to nanos where supported.","Reduce the Flink TIMESTAMP precision to 3 (TIMESTAMP(3)) if legacy mode must stay enabled.","Truncate/convert timestamps to millis before writing when on the legacy path.","Update the table/connector config so the timestamp mapping flag matches the actual column precision."],"exampleFix":"// before\nTIMESTAMP(6) with legacyTimestampMapping = true\n// after\nTIMESTAMP(3) with legacyTimestampMapping = true  // or keep TIMESTAMP(6) and set legacyTimestampMapping = false","handlingStrategy":"validation","validationCode":"TimestampType ts = (TimestampType) logicalType;\nif (legacyMapping && ts.getPrecision() > 3) {\n  throw new IllegalArgumentException(\"TIMESTAMP(\" + ts.getPrecision() + \") requires legacyTimestampMapping=false\");\n}","typeGuard":null,"tryCatchPattern":"try { schema = AvroSchemaConverter.convertToSchema(type, legacy); } catch (IllegalArgumentException e) { /* retry with legacy=false or degrade precision */ }","preventionTips":["Match timestamp precision in DDL to the mapping mode (<=3 for legacy).","Standardize on TIMESTAMP(3) unless micros are truly needed.","Document the legacy-mapping flag next to precision in table configs."],"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-14T16:17:12.679Z"}