amitvijapur opened a new pull request, #25629:
URL: https://github.com/apache/datafusion/pull/25629

   ## Which issue does this PR close?
   
   - Closes #25573.
   
   ## Rationale for this change
   
   `next_value` and `prev_value` step `IntervalDayTime` and 
`IntervalMonthDayNano` by adding or subtracting a one-unit interval through 
Arrow's `AddAssign`/`SubAssign`, which `expect` on component overflow in debug 
builds and wrap silently in release. A valid value whose smallest component 
sits at its bound, such as `IntervalDayTime(0, i32::MAX)`, therefore makes 
`satisfy_greater` panic with `IntervalDayTime overflow` in a debug build, and 
produce a wrapped, wrong bound in release. The type-wide `MAX`/`MIN` are 
already mapped to unbounded by `value_transition!`, so the panic is only 
reachable for values strictly inside the range.
   
   ## What changes are included in this PR?
   
   Both types derive `Ord` in field order, so their ordering is lexicographic 
over `(days, milliseconds)` and `(months, days, nanoseconds)`, and the adjacent 
value at a component bound is a carry into the next component: the successor of 
`(0, i32::MAX)` is `(1, i32::MIN)`. Two small helpers do that carry and replace 
the `OneTrait` impls for the two types; `MAX`/`MIN` still become unbounded 
exactly as before.
   
   ## Are these changes tested?
   
   A new test in `interval_arithmetic.rs` checks the carry in both directions 
at the millisecond, nanosecond and day boundaries, that values away from a 
bound only move their smallest component, that the type-wide extremes still 
become unbounded, and the exact reproduction from the issue through 
`satisfy_greater`, asserting the propagated bounds. The existing 44 interval 
tests pass unchanged.
   
   ## Are there any user-facing changes?
   
   No API change. Interval-typed expressions are excluded from physical 
constraint propagation today, so this is reachable through the Rust API rather 
than SQL.
   
   Written with AI assistance (Claude Code); I traced the panic to Arrow's 
`AddAssign`, checked the derive order that makes the carry correct, and ran the 
tests myself.
   


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