Apache Iceberg version
main @ 49b89a8
Query engine
Flink 2.1
Please describe the bug
AvroToRowDataConverters.convertToTimestamp() mis-converts microsecond-precision (precision 4-6) timestamps read from Avro. For the leftover sub-millisecond microseconds (Math.floorMod(timeLong, 1000L), range 0-999), it multiplies by 1_000_000 instead of 1000 before passing the result as nanoOfMillisecond to TimestampData.fromEpochMillis(long, int) (flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/formats/avro/AvroToRowDataConverters.java line 234-236). TimestampData's constructor requires nanoOfMillisecond to be in [0, 999999]; any non-zero leftover microsecond value exceeds that bound and the call throws IllegalArgumentException.
Two sibling conversions in the same module perform the same micros-to-nanos step correctly, multiplying by 1000: StructRowData.getTimestamp() (flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/StructRowData.java line 210) and FlinkValueReaders.TimestampMicrosReader.read() (flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/FlinkValueReaders.java line 184).
The faulty branch was added in PR #15475 ("Flink: Add Nanosecond Precision Support for Flink-Iceberg Integration").
Steps to reproduce
Read an Avro record into a RowType/LocalZonedTimestampType column with precision <= 6 where the source long has a non-zero leftover after dividing by 1000 (i.e. the value isn't aligned to a whole millisecond). Expected: the timestamp converts normally. Actual: AvroToRowDataConverters.convertToTimestamp() throws IllegalArgumentException from TimestampData.<init>.
Additional context
N/A — covered above.
Apache Iceberg version
main @ 49b89a8
Query engine
Flink 2.1
Please describe the bug
AvroToRowDataConverters.convertToTimestamp()mis-converts microsecond-precision (precision 4-6) timestamps read from Avro. For the leftover sub-millisecond microseconds (Math.floorMod(timeLong, 1000L), range 0-999), it multiplies by1_000_000instead of1000before passing the result asnanoOfMillisecondtoTimestampData.fromEpochMillis(long, int)(flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/formats/avro/AvroToRowDataConverters.javaline 234-236).TimestampData's constructor requiresnanoOfMillisecondto be in[0, 999999]; any non-zero leftover microsecond value exceeds that bound and the call throwsIllegalArgumentException.Two sibling conversions in the same module perform the same micros-to-nanos step correctly, multiplying by
1000:StructRowData.getTimestamp()(flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/StructRowData.javaline 210) andFlinkValueReaders.TimestampMicrosReader.read()(flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/FlinkValueReaders.javaline 184).The faulty branch was added in PR #15475 ("Flink: Add Nanosecond Precision Support for Flink-Iceberg Integration").
Steps to reproduce
Read an Avro record into a
RowType/LocalZonedTimestampTypecolumn with precision <= 6 where the sourcelonghas a non-zero leftover after dividing by 1000 (i.e. the value isn't aligned to a whole millisecond). Expected: the timestamp converts normally. Actual:AvroToRowDataConverters.convertToTimestamp()throwsIllegalArgumentExceptionfromTimestampData.<init>.Additional context
N/A — covered above.