SAY-5 opened a new pull request, #22408:
URL: https://github.com/apache/datafusion/pull/22408

   ## Which issue does this PR close?
   
   - Closes #22215.
   
   ## Rationale for this change
   
   `date_bin` panics with `attempt to subtract with overflow` when the source 
timestamp sits near `i64::MIN` because `compute_distance` does `time_diff - 
(time_diff % stride)` and then `time_delta - stride` on raw `i64`. The scalar 
pipeline already maps `Err` from `bin_fn` into `NULL`, so the fix is to surface 
the overflow as a normal error.
   
   ## What changes are included in this PR?
   
   - Convert `compute_distance` to return `Result<i64>` and use `checked_sub`.
   - Propagate the result through `date_bin_nanos_interval` and 
`date_bin_months_interval`, plus replace the trailing `origin + time_delta` 
with `checked_add`.
   
   ## Are these changes tested?
   
   Yes. Added `test_date_bin_compute_distance_i64_min` which previously 
panicked and now returns `NULL`. Ran `cargo test -p datafusion-functions --lib 
-- datetime::date_bin`, `cargo fmt --check`, and `cargo clippy -p 
datafusion-functions --lib --tests --no-deps`.
   
   ## Are there any user-facing changes?
   
   Queries that previously panicked on extreme timestamps now return `NULL` 
(consistent with the existing out-of-range behavior covered by 
`test_date_bin_out_of_range`).
   


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