viirya opened a new pull request, #26332: URL: https://github.com/apache/datafusion/pull/26332
## Which issue does this PR close? - Follow-up to #25815, from https://github.com/apache/datafusion/pull/25815#discussion_r4122735316. ## Rationale for this change In #25815, @alamb asked why a plan still had a `SortExec` when ordering propagation should remove it. That sort was the `TopK(fetch=n)` from the `ORDER BY ... LIMIT n` subquery used to produce ordered input. The outer sort, the one the test was about, had already been removed. Reading the input from a table declared sorted makes the plans show this directly: no sort at all when the ordering propagates, and only the final sort when it does not. ## What changes are included in this PR? Test-only. In `datetime/timestamps.slt`, the seven ordering-propagation `EXPLAIN` tests through `date_bin`, `date_trunc` and `from_unixtime` (plus the result queries next to them) now read from CSV files written with `COPY ... TO` and registered with `CREATE EXTERNAL TABLE ... WITH ORDER`. This follows the pattern in `order.slt`. Each `DataSourceExec` reports the declared `output_ordering`. - The five cases where the sort is removed (timezone-free `from_unixtime`, timezone-free `date_bin`, coarse-precision values outside the nanosecond range, positive month stride, nested `date_trunc`) now have no `SortExec`. - The `America/Goose_Bay` case keeps exactly one `SortExec`, the required final sort. - The data is unchanged: `Timestamp(Second)` columns come from `TIMESTAMP(0)`, the coarse-precision case still uses ±10,000,000,000 seconds, and every query result is unchanged. The Goose Bay result query moved next to its `EXPLAIN`. I did not find any other `date_bin`/`date_trunc` ordering plan tests that use the `ORDER BY ... LIMIT` subquery pattern. The related tests in `group_by.slt` and `sort_pushdown.slt` already use `WITH ORDER`. ## What is the testing strategy for this PR? This PR only changes tests. `datetime/timestamps.slt` passes. ## Are there any user-facing changes? No. cc @alamb This pull request and its description were written by Isaac. -- 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]
