thswlsqls opened a new issue, #17075:
URL: https://github.com/apache/iceberg/issues/17075

   **Apache Iceberg version**
   main @ 49b89a8c5
   
   **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.
   
   ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to