{"record":{"id":"7127b43ea63ca908","repo":"apache/iceberg","slug":"avro-does-not-support-time-type-with-precision-s","errorCode":null,"errorMessage":"Avro does not support TIME type with precision: %s, it only supports precision less than 3.","messagePattern":"Avro does not support TIME type with precision: (.+?), it only supports precision less than 3\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/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.3/flink/src/main/java/org/apache/iceberg/flink/formats/avro/typeutils/AvroSchemaConverter.java#L520-L556","documentation":"Thrown when converting a Flink TIME (without time zone) type to an Avro schema whose precision exceeds 3. Avro represents time as timeMillis (an int with millisecond precision), so TIME(4)-TIME(9) cannot be represented. The message is slightly misleading: precision must be 3 or less (not strictly less than 3).","triggerScenarios":"Calling AvroSchemaConverter.convertToSchema with a TimeType of precision > 3.","commonSituations":"Flink tables with TIME(6) or TIME(9) columns (e.g. microsecond time from upstream systems) serialized to Avro files or Avro-encoded Kafka records.","solutions":["Cast the column to TIME(3) (or TIME(0)) before writing.","Define the column as TIME(3) in the table DDL to match Avro's timeMillis.","If sub-millisecond precision is required, use a different format (Parquet) or store as an integer/bigint.","Round or truncate time values at the source pipeline stage."],"exampleFix":"// before\n// `t` TIME(6)\n// after\n// Flink DDL: `t` TIME(3)  -- maps to avro timeMillis","handlingStrategy":"validation","validationCode":"if (logicalType instanceof TimeType && ((TimeType) logicalType).getPrecision() > 3) { throw new IllegalArgumentException(\"Cast TIME(p) to TIME(3) before Avro serialization\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define TIME columns as TIME(3) — Avro's timeMillis is millisecond precision.","Truncate micro/nanosecond time fields at the source.","Avoid TIME(6)/TIME(9) defaults from upstream connectors.","Use Parquet or bigint storage when sub-millisecond time precision is required."],"tags":["flink","avro","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"}