{"record":{"id":"408d0028e50f483d","repo":"apache/iceberg","slug":"avro-does-not-support-time-type-with-precision-408d00","errorCode":null,"errorMessage":"Avro does not support TIME type with precision: \" + precision + \", it only supports precision less than 3.","messagePattern":"Avro does not support TIME 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":538,"sourceCode":"            avroLogicalType = LogicalTypes.timestampMicros();\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 6.\");\n          }\n          timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());\n          return nullable ? nullableSchema(timestamp) : timestamp;\n        }\n      case DATE:\n        // use int to represents Date\n        Schema date = LogicalTypes.date().addToSchema(SchemaBuilder.builder().intType());\n        return nullable ? nullableSchema(date) : date;\n      case TIME_WITHOUT_TIME_ZONE:\n        precision = ((TimeType) logicalType).getPrecision();\n        if (precision > 3) {\n          throw new IllegalArgumentException(\n              \"Avro does not support TIME type with precision: \"\n                  + precision\n                  + \", it only supports precision less than 3.\");\n        }\n        // use int to represents Time, we only support millisecond when deserialization\n        Schema time = LogicalTypes.timeMillis().addToSchema(SchemaBuilder.builder().intType());\n        return nullable ? nullableSchema(time) : time;\n      case DECIMAL:\n        DecimalType decimalType = (DecimalType) logicalType;\n        // store BigDecimal as byte[]\n        Schema decimal =\n            LogicalTypes.decimal(decimalType.getPrecision(), decimalType.getScale())\n                .addToSchema(SchemaBuilder.builder().bytesType());\n        return nullable ? nullableSchema(decimal) : decimal;\n      case ROW:\n        RowType rowType = (RowType) logicalType;\n        List<String> fieldNames = rowType.getFieldNames();\n        // we have to make sure the record name is different in a Schema","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L520-L556","documentation":"Avro's time-millis logical type only supports millisecond precision, so when converting a Flink TIME type the converter rejects precision greater than 3 with IllegalArgumentException. TIME(0..3) maps to LogicalTypes.timeMillis stored as an int.","triggerScenarios":"Calling AvroSchemaConverter.convertToSchema with a Flink TimeType whose precision is > 3 (directly, or via a RowType field processed by fieldBuilder).","commonSituations":"Flink DDL declaring TIME(6) or TIME(9) (some connectors/UDFs emit high-precision TIME), then running it through Avro-based serialization (e.g. Avro encoding of Flink state or data).","solutions":["Change the column to TIME(3) (or lower) in the table/DDL definition.","Cast the TIME column to TIME(3) before conversion, e.g. CAST(col AS TIME(3)).","Truncate precision at the source (UDF/connector) so TIME columns never exceed millisecond precision."],"exampleFix":"// before\nCREATE TABLE t (tm TIME(6));\n// after\nCREATE TABLE t (tm TIME(3));","handlingStrategy":"validation","validationCode":"if (type instanceof TimeType) {\n  Preconditions.checkArgument(((TimeType) type).getPrecision() <= 3,\n      \"Avro supports TIME precision <= 3, got \" + ((TimeType) type).getPrecision());\n}","typeGuard":"boolean isAvroCompatibleTime(LogicalType t) {\n  return !(t instanceof TimeType tt) || tt.getPrecision() <= 3;\n}","tryCatchPattern":"try {\n  Schema s = AvroSchemaConverter.convertToSchema(logicalType, rowName);\n} catch (IllegalArgumentException e) {\n  // cast TIME to TIME(3) upstream or fail fast with schema guidance\n}","preventionTips":["Use TIME(3) (the max Avro-compatible precision) in table DDL","Cast TIME columns in SQL before they reach serialization","Add a schema-compat preflight check when schemas come from external sources"],"tags":["avro","flink","schema-conversion","time-precision"],"backgroundTag":"unsupported-dtype","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"}