xudong963 opened a new pull request, #27849:
URL: https://github.com/apache/datafusion/pull/27849
## Which issue does this PR close?
- Backport of #27732 to `branch-56`, for #24463, which lists it as a
regression in 56.
- Closes #25464 for the 56 line.
#27732 has not merged to `main` yet, so this stays a draft until it does. If
it changes in review, I will replace the commit here with the merge commit.
This builds on the backport of #27547 (#27848), so this branch has both
commits. Only the last commit is new here. I will rebase once #27848 merges.
## Rationale for this change
#25409, new in 56, stopped `date_trunc` from propagating its input ordering
for timezone-aware timestamps. After #27547, `hour` and coarser granularities
still drop it for every timezone, including `UTC` and fixed offsets. So since
56.0.0, sorting or grouping by `date_trunc('day', ts)` over input ordered on
`ts` adds a sort and loses clustered aggregation. #27732 keeps the ordering
wherever local truncation cannot reverse, which it checks exactly at each UTC
offset transition of the zone.
## What changes are included in this PR?
A clean cherry-pick of #27732 (`b32121f`, its current head) with `-x`, on
top of the backport of #27547. No conflicts.
## What is the testing strategy for this PR?
The `date_trunc` unit tests, including
`timezone_offsets_are_constant_outside_transition_scan_window`, and
`datetime/timestamps.slt` pass on this branch.
Applied on `branch-56` together with the backports of #27021, #27150 and
#26261 (opened alongside this one), the full sqllogictest suite, `cargo fmt
--check` and clippy on the touched crates also pass.
## Are there any user-facing changes?
Plans only: no `SortExec`, and clustered aggregation, for `date_trunc` at
`day` or coarser in zones where truncation keeps the order, and at `hour` in
zones without transitions such as `UTC`. Results are unchanged. No 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]