github-actions[bot] commented on code in PR #62347:
URL: https://github.com/apache/doris/pull/62347#discussion_r3063631564
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildrenPropertiesRegulator.java:
##########
@@ -229,9 +230,24 @@ private boolean requireGather(PhysicalProperties
requiredChildProperty) {
* no matter x.ndv is high or not, it is not worthwhile to shuffle A and B
by x
* and hence we forbid one phase agg */
private boolean banAggUnionAll(PhysicalHashAggregate<? extends Plan>
aggregate) {
- return aggregate.getAggMode() == AggMode.INPUT_TO_RESULT
- && children.get(0).getPlan() instanceof PhysicalUnion
- && !((PhysicalUnion) children.get(0).getPlan()).isDistinct();
+ if (aggregate.getAggMode() == AggMode.INPUT_TO_RESULT &&
children.get(0).getPlan() instanceof PhysicalUnion
+ && !((PhysicalUnion) children.get(0).getPlan()).isDistinct()) {
+ GroupExpression gExprUnion = children.get(0);
+ List<Group> groups = gExprUnion.children();
+ Pair<Cost, List<PhysicalProperties>> pair =
gExprUnion.getLowestCostTable().get(requiredProperties.get(0));
+ int i = 0;
+ // If none of the union inputs have PhysicalDistribute, allow
one-phase aggregation
+ for (Group group : groups) {
+ GroupExpression groupExpression =
group.getBestPlan(pair.second.get(i));
+ i++;
+ if (groupExpression != null && groupExpression.getPlan()
instanceof PhysicalDistribute) {
Review Comment:
This only checks whether the *root* of each `UNION ALL` child plan is
`PhysicalDistribute`. That misses common Nereids shapes like
`PhysicalProject(PhysicalDistribute(...))` or
`PhysicalFilter(PhysicalDistribute(...))`: `ChildOutputPropertyDeriver`
preserves the child distribution through those wrappers, so the best plan for
`pair.second.get(i)` can still be shuffled even though its root is not
`PhysicalDistribute`.
In that case `banAggUnionAll()` returns `false` and re-enables one-phase agg
even though the union arm is still shuffled, which is exactly the case this
guard is supposed to reject. Please walk through property-preserving wrappers
(at least `Project`/`Filter`/`Limit`) when checking for an underlying
distribute node, instead of testing the root node only.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]