alamb commented on issue #14991:
URL: https://github.com/apache/datafusion/issues/14991#issuecomment-2698391616

   ```sql
   > CREATE TABLE test_table (
       col_i32 INT,
       col_u32 INT UNSIGNED
   ) as VALUES
   ( NULL,        NULL),
   ( -2147483648, 0),
   ( -2147483648, 0),
   ( 100,         100),
   ( 2147483647,  4294967295),
   ( NULL,        NULL),
   ( -2147483648, 0),
   ( -2147483648, 0),
   ( 100,         100),
   ( 2147483646,  4294967294),
   ( 2147483647,  4294967295 )
   
   ;
   0 row(s) fetched.
   Elapsed 0.010 seconds.
   
   > 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;
   
+---------------+---------------------------------------------------------------------------------------------------------------------------+
   | plan_type     | plan                                                       
                                                               |
   
+---------------+---------------------------------------------------------------------------------------------------------------------------+
   | logical_plan  | Projection: test_table.col_i32, sum(test_table.col_u32) AS 
sum_col_u32                                                    |
   |               |   Aggregate: groupBy=[[test_table.col_i32]], 
aggr=[[sum(CAST(test_table.col_u32 AS UInt64))]]                             |
   |               |     Sort: test_table.col_i32 ASC NULLS LAST, fetch=10      
                                                               |
   |               |       TableScan: test_table projection=[col_i32, col_u32]  
                                                               |
   | physical_plan | ProjectionExec: expr=[col_i32@0 as col_i32, 
sum(test_table.col_u32)@1 as sum_col_u32]                                     |
   |               |   AggregateExec: mode=FinalPartitioned, gby=[col_i32@0 as 
col_i32], aggr=[sum(test_table.col_u32)], ordering_mode=Sorted  |
   |               |     SortExec: expr=[col_i32@0 ASC NULLS LAST], 
preserve_partitioning=[true]                                               |
   |               |       CoalesceBatchesExec: target_batch_size=8192          
                                                               |
   |               |         RepartitionExec: partitioning=Hash([col_i32@0], 
16), input_partitions=16                                          |
   |               |           RepartitionExec: 
partitioning=RoundRobinBatch(16), input_partitions=1                            
               |
   |               |             AggregateExec: mode=Partial, gby=[col_i32@0 as 
col_i32], aggr=[sum(test_table.col_u32)], ordering_mode=Sorted |
   |               |               SortExec: TopK(fetch=10), expr=[col_i32@0 
ASC NULLS LAST], preserve_partitioning=[false]                    |
   |               |                 DataSourceExec: partitions=1, 
partition_sizes=[1]                                                         |
   |               |                                                            
                                                               |
   
+---------------+---------------------------------------------------------------------------------------------------------------------------+
   2 row(s) fetched.
   Elapsed 0.006 seconds.
   ```
   
   I guess I forgot that we did eventually unify the implementation 🎉 
   
   
   In that case then I think it would make sense to pass existing ordering 
information along to the aggregates 👍  


-- 
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

Reply via email to