CodeMasterXZT opened a new pull request, #11899:
URL: https://github.com/apache/arrow-rs/pull/11899

   # Which issue does this PR close?
   
   Closes #11893.
   
   # Rationale for this change
   
   In `arrow-array/src/temporal_conversions.rs`, `time64us_to_time` and 
`time64ns_to_time` (as well as `time32s_to_time` and `time32ms_to_time`) 
converted seconds using `as u32`. For large `Time64` inputs (e.g. `(2^32 + 5) * 
1_000_000_000` ns), the high 32 bits of seconds were truncated, causing values 
far outside one day to wrap around into valid times within a day (e.g. 
`00:00:05`) instead of returning `None`.
   
   # What changes are included in this PR?
   
   - Replaced `as u32` conversions in `time32s_to_time`, `time32ms_to_time`, 
`time64us_to_time`, and `time64ns_to_time` with `u32::try_from(..).ok()?`.
   - Added unit tests asserting that out-of-bounds / wrapped values for 
`Time32` and `Time64` consistently return `None` while valid values continue to 
convert as expected.
   
   # Are these changes tested?
   
   Yes, new unit tests covering out-of-bounds, negative, extreme 
(`i64::MAX`/`i64::MIN`), and wrapped inputs have been added to 
`temporal_conversions::tests`. Downstream tests in `arrow-cast` and 
`arrow-arith` continue to pass.
   
   # Are there any user-facing changes?
   
   Out-of-bounds `Time64` values exceeding 2^32 seconds now return `None` 
rather than wrapping around to valid timestamps.
   


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

Reply via email to