{"record":{"id":"81a20f4e9fdd7fa1","repo":"apache/iceberg","slug":"avro-does-not-support-time-type-with-precision","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: (.+?), it only supports precision less than 3\\.","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/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.1/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L520-L556","documentation":"Avro's timeMillis logical type has millisecond resolution and the converter stores TIME as int. Flink TIME(p) with p > 3 cannot be represented, so conversion fails with IllegalArgumentException instead of losing precision.","triggerScenarios":"Calling AvroSchemaConverter.convertToSchema on a row containing TIME(4) through TIME(9).","commonSituations":"Flink DDL with high-precision TIME columns mapped to an Avro sink; defaults changed from TIME(0)/TIME(3) to higher precision by framework code.","solutions":["Declare the TIME column with precision <= 3 (e.g. TIME(0) or TIME(3))","Cast the column to TIME(3) before serialization","Store the time as string or BIGINT manually if higher precision is needed"],"exampleFix":"// before\ncolumns: TIME(6)\nSchema avro = AvroSchemaConverter.convertToSchema(rowType, \"rec\", false);\n// after\ncolumns: TIME(3)\nSchema avro = AvroSchemaConverter.convertToSchema(rowType, \"rec\", false);","handlingStrategy":"validation","validationCode":"if (timeType.getPrecision() > 3) {\n  throw new IllegalArgumentException(\"TIME precision must be <= 3 for Avro; got \" + timeType.getPrecision());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare TIME columns as TIME(0) or TIME(3)","Cast high-precision TIME to TIME(3) at the sink boundary","Check precision defaults of the upstream framework that generates the DDL"],"tags":["avro","flink","time-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-23T08:17:48.524Z"}