comphead commented on issue #15886: URL: https://github.com/apache/datafusion/issues/15886#issuecomment-2836896989
Simpler test case ORDER BY in outer query ``` > explain select x.* from (select 1 a union all select null) x order by a nulls last; +---------------+------------------------------------------------------------+ | plan_type | plan | +---------------+------------------------------------------------------------+ | physical_plan | ┌───────────────────────────┐ | | | │ SortPreservingMergeExec │ | | | │ -------------------- │ | | | │ a ASC NULLS LAST │ | | | └─────────────┬─────────────┘ | | | ┌─────────────┴─────────────┐ | | | │ UnionExec ├──────────────┐ | | | └─────────────┬─────────────┘ │ | | | ┌─────────────┴─────────────┐┌─────────────┴─────────────┐ | | | │ ProjectionExec ││ ProjectionExec │ | | | │ -------------------- ││ -------------------- │ | | | │ a: 1 ││ a: NULL │ | | | └─────────────┬─────────────┘└─────────────┬─────────────┘ | | | ┌─────────────┴─────────────┐┌─────────────┴─────────────┐ | | | │ PlaceholderRowExec ││ PlaceholderRowExec │ | | | └───────────────────────────┘└───────────────────────────┘ | | | | +---------------+------------------------------------------------------------+ 1 row(s) fetched. Elapsed 0.009 seconds. ``` should be the same as ORDER BY in CTE ``` > explain select x.* from (select 1 a union all select null order by a nulls last) x; +---------------+------------------------------------------------------------+ | plan_type | plan | +---------------+------------------------------------------------------------+ | physical_plan | ┌───────────────────────────┐ | | | │ UnionExec ├──────────────┐ | | | └─────────────┬─────────────┘ │ | | | ┌─────────────┴─────────────┐┌─────────────┴─────────────┐ | | | │ ProjectionExec ││ ProjectionExec │ | | | │ -------------------- ││ -------------------- │ | | | │ a: 1 ││ a: NULL │ | | | └─────────────┬─────────────┘└─────────────┬─────────────┘ | | | ┌─────────────┴─────────────┐┌─────────────┴─────────────┐ | | | │ PlaceholderRowExec ││ PlaceholderRowExec │ | | | └───────────────────────────┘└───────────────────────────┘ | | | | +---------------+------------------------------------------------------------+ 1 row(s) fetched. Elapsed 0.008 seconds. ``` But it is not. Sort is gone -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org