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

   ## Which issue does this PR close?
   
   Closes #26108.
   
   ## Rationale for this change
   
   Queries over ordered timestamp data can perform unnecessary sorts after 
timestamp conversions. Propagating ordering through these conversions allows 
the optimizer to eliminate redundant sorts, including expressions that combine 
`to_timestamp_micros`, `date_bin`, and `to_unixtime`.
   
   ## What changes are included in this PR?
   
   - Add ordering propagation for single-argument `to_timestamp_micros` calls 
with integer input.
   - Add ordering propagation for single-argument `to_unixtime` calls with 
integer, date, or timestamp input.
   - Preserve input sort direction and NULL placement.
   - Retain conservative strict-ordering metadata so precision reduction does 
not incorrectly eliminate sorting by subsequent keys.
   
   ## What is the testing strategy for this PR?
   
   Unit tests verify ordering against runtime conversions across supported 
types, sort directions, NULL placement, timestamp units, and timezones.
   
   SQL tests in `datetime/timestamps.slt` verify sort elimination and query 
results, conversion boundaries, and a case where conversion creates ties and 
sorting by a subsequent key remains necessary.
   
   Validation passed:
   
   - The three added unit tests.
   - `cargo test -p datafusion-sqllogictest --test sqllogictests -- 
datetime/timestamps.slt`
   - `cargo fmt --all -- --check`
   - `git diff --check`
   - `cargo clippy --all-targets --all-features -- -D warnings`
   - `uv run ./dev/rust_lint.sh`
   
   ## Are there any user-facing changes?
   
   Yes. Queries using these conversions on ordered input can avoid redundant 
sorts. There are no changes to function results or public APIs.
   


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