jayzhan211 opened a new issue, #15818:
URL: https://github.com/apache/datafusion/issues/15818

   ### Is your feature request related to a problem or challenge?
   
   ```
   statement ok
   create table t(a int, b int) as values (1, 2), (2, 3);
   
   query I
   select sum(a) from (select a from t order by a) group by a;
   ----
   1
   2
   
   query TT
   explain select sum(a) from (select a from t order by a) group by a;
   ----
   logical_plan
   01)Projection: sum(t.a)
   02)--Aggregate: groupBy=[[t.a]], aggr=[[sum(CAST(t.a AS Int64))]]
   03)----TableScan: t projection=[a]
   physical_plan
   01)ProjectionExec: expr=[sum(t.a)@1 as sum(t.a)]
   02)--AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[sum(t.a)]
   03)----CoalesceBatchesExec: target_batch_size=8192
   04)------RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=4
   05)--------RepartitionExec: partitioning=RoundRobinBatch(4), 
input_partitions=1
   06)----------AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[sum(t.a)]
   07)------------DataSourceExec: partitions=1, partition_sizes=[1]
   
   ```
   
   In this query, we know the `a` is ordered, when we do the grouped 
aggregation, we can run with `GroupOrdering::Full` mode. However, this is not 
the case now.
   
   ### Describe the solution you'd like
   
   Find a way to keep ordering information and then leverage on it for 
optimization.
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


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