jayzhan211 commented on issue #14991: URL: https://github.com/apache/datafusion/issues/14991#issuecomment-2700784561
``` query TT explain select col_i32, sum(col_u32) sum_col_u32 from (select * from test_table order by col_i32 limit 10) group by col_i32 ---- logical_plan 01)Projection: test_table.col_i32, sum(test_table.col_u32) AS sum_col_u32 02)--Aggregate: groupBy=[[test_table.col_i32]], aggr=[[sum(CAST(test_table.col_u32 AS UInt64))]] 03)----Sort: test_table.col_i32 ASC NULLS LAST, fetch=10 04)------TableScan: test_table projection=[col_i32, col_u32] physical_plan 01)ProjectionExec: expr=[col_i32@0 as col_i32, sum(test_table.col_u32)@1 as sum_col_u32] 02)--AggregateExec: mode=FinalPartitioned, gby=[col_i32@0 as col_i32], aggr=[sum(test_table.col_u32)], ordering_mode=Sorted 03)----SortExec: expr=[col_i32@0 ASC NULLS LAST], preserve_partitioning=[true] 04)------CoalesceBatchesExec: target_batch_size=8192 05)--------RepartitionExec: partitioning=Hash([col_i32@0], 4), input_partitions=4 06)----------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1 07)------------AggregateExec: mode=Partial, gby=[col_i32@0 as col_i32], aggr=[sum(test_table.col_u32)], ordering_mode=Sorted 08)--------------SortExec: TopK(fetch=10), expr=[col_i32@0 ASC NULLS LAST], preserve_partitioning=[false] 09)----------------DataSourceExec: partitions=1, partition_sizes=[1] ``` AggregateExec has input ordering mode sorted which indicates it knows the group columns are ordered. `AggregateExec: mode=FinalPartitioned, gby=[col_i32@0 as col_i32], aggr=[sum(test_table.col_u32)], ordering_mode=Sorted` I think we need an example of query that has not yet pass the ordering information to AggregateExec, then we optimize based on that -- 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