EeshanBembi commented on code in PR #16905: URL: https://github.com/apache/datafusion/pull/16905#discussion_r2233562643
########## datafusion/core/src/physical_planner.rs: ########## @@ -886,6 +887,26 @@ impl DefaultPhysicalPlanner { "SortExec requires at least one sort expression" ); }; + + // Check if we can use PartialSortExec instead of SortExec Review Comment: We do still need this in the planner. EnforceSorting is a bottom‑up optimizer that only looks at each SortExec and its direct child, so it can’t see sibling branches under a UnionExec to ensure they all use the same partial‑sort strategy. UnionExec itself merely concatenates sorted inputs without merging, so mixing full and partial sorts would break downstream merge semantics. By contrast, DefaultPhysicalPlanner builds each subtree top‑down and knows when two sorts feed into the same UnionExec, allowing it to inject a uniform PartialSortExec and preserve correct SortPreservingMergeExec behavior. -- 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