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

   ## Which issue does this PR close?
   
   Closes #24683.
   Related to #25407.
   
   ## Rationale for this change
   
   An ordered signed integer column does not necessarily remain ordered after 
negation: the minimum value wraps to itself. Treating negation as always 
reversing order can remove a required sort and return incorrectly ordered rows. 
Negating inferred interval endpoints can also raise an overflow error even 
though array evaluation uses wrapping negation.
   
   ## What changes are included in this PR?
   
   - Stop deriving reversed ordering when the input range may contain the 
signed minimum, while preserving existing Singleton properties and reversal for 
known safe ranges.
   - Use unbounded intervals for potentially wrapping signed integer negation 
in forward and reverse constraint propagation, including singleton MIN ranges.
   - Add regression cases to the existing `order.slt` and update the expected 
plan for negation of an ordered BIGINT expression.
   
   Runtime scalar and array negation semantics are unchanged. This conservative 
fix can retain additional sorts when safe bounds are unavailable, including 
after widening casts; improving cast range propagation is left to separate work.
   
   ## What is the testing strategy for this PR?
   
   - Reproduced incorrect ordering for all four signed integer widths and an 
inferred-endpoint overflow before the fix.
   - Unit tests cover wrapping and safe ranges, both sort directions and NULL 
placements, unknown ranges, Singleton properties, and forward/reverse 
containment of Int8 values.
   - SQL tests cover sorting and filtering at MIN, MIN mixed with NULL, and 
double negation on bounded and unbounded inputs.
   - Passed the 10 negation unit tests and the `order.slt` and `filter.slt` 
regression suites.
   - Passed `cargo fmt --all`, `cargo clippy --all-targets --all-features -- -D 
warnings`, and the complete `uv run ./dev/rust_lint.sh` checks.
   
   ## Are there any user-facing changes?
   
   Queries involving signed minimum negation retain necessary sorts and no 
longer fail solely because an inferred negation endpoint overflows. Some range 
refinement and sort elimination become more conservative. No public API changes.
   


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