adiranjan25 opened a new pull request, #19222:
URL: https://github.com/apache/iceberg/pull/19222

   ## Summary
   
   Fix silent arithmetic overflow when Flink writes nanosecond-precision 
timestamps to Iceberg Parquet and Avro data files.
   
   The existing conversion performs unchecked multiplication and addition, 
allowing timestamps outside the signed 64-bit nanosecond range to be silently 
written as incorrect timestamp values.
   
   ## Implementation
   
   Introduce a shared boundary-safe conversion in `DateTimeUtil` and apply it 
to the Flink Parquet and Avro timestamp nanosecond writers across Flink 1.20, 
2.2, and 2.3.
   
   A straightforward combination of `Math.multiplyExact` and `Math.addExact` is 
insufficient because the intermediate multiplication can underflow for valid 
timestamps near `Long.MIN_VALUE`.
   
   The implementation avoids this intermediate underflow while rejecting 
genuinely unrepresentable timestamps.
   
   ## Validation
   
   - Independently reproduced the original writer overflow behavior.
   - Validated the arithmetic against a BigInteger reference using 200,000 
randomized cases.
   - Added direct utility tests for signed 64-bit nanosecond boundaries.
   - Added regression coverage for Parquet and Avro.
   - Covered timestamp types with and without timezone adjustment.
   - Verified exact timestamp round-trip behavior at representable boundaries.
   - Validated Flink 1.20, 2.2, and 2.3.
   - Full selected test results: 311 passed, 38 skipped, zero failures or 
errors.
   - All affected module Spotless checks passed.
   
   ## Scope
   
   This change focuses on the Parquet and Avro data file writer paths. Other 
timestamp conversion paths may warrant separate investigation.
   
   Closes #19218.


-- 
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