Dandandan commented on PR #6950:
URL: 
https://github.com/apache/arrow-datafusion/pull/6950#issuecomment-1634644376

   > According to `CombinePartialFinalAggregate` rule, when planner sees 
`AggregateMode::Partial` + `AggregateMode::Final` or `AggregateMode::Partial` + 
`AggregateMode::FinalPartitioned`, it replaces these immediate operators with 
`AggregateMode::Single`. For second case changing distribution requirement to 
`Distribution::HashPartitioned` makes sense. However, for first case 
distribution requirement should be `SinglePartition` I guess.
   > 
   > With the proposed changes, `AggregateMode::Single` will require 
`vec![Distribution::HashPartitioned(vec![])]` (where group by is empty). when 
it is constructed from `AggregateMode::Partial` + `AggregateMode::Final` stack.
   > 
   > Will this requirement add `RepartitionExec(hash)` during planning?
   
   Ah I missed that part. 
   I missed the part that `Final` + `FinalPartitioned` is also being converted 
to `Single`. I think the correct way (that avoids planning errors) would be a 
`Single` that requires `SinglePartition` in that case.
   
   Currently the optimization rule runs after the `RepartitionExec(hash)` and 
`CoalescePartitions` are added so it *should* already have those requirements, 
but I think it's better to generate a correct plan, otherwise we could 
introduce errors later on (e.g. by a rule that removes unnecessary 
`RepartitionExec` / `CoalescePartitions` or by using the `Single` mode directly 
before the required partitioning is added).


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to