[fix](nereids) fix colocate agg + join compute wrong result (#48934) (#51313)

cherry pick from #48934
This commit is contained in:
924060929
2025-05-28 15:30:58 +08:00
committed by GitHub
parent 91abfe38cd
commit 25f5d5fb1e
2 changed files with 99 additions and 0 deletions

View File

@ -1066,6 +1066,21 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
// Set colocate info in agg node. This is a hint for local shuffling to decide which type of
// local exchanger will be used.
aggregationNode.setColocate(true);
Plan child = aggregate.child();
// we should set colocate = true, when the same LogicalAggregate generate two PhysicalHashAggregates
// in one fragment:
//
// agg(merge finalize) <- current, set colocate = true
// |
// agg(update serialize) <- child, also set colocate = true
if (aggregate.getAggregateParam().aggMode.consumeAggregateBuffer
&& child instanceof PhysicalHashAggregate
&& !((PhysicalHashAggregate<Plan>) child).getAggregateParam().aggMode.consumeAggregateBuffer
&& inputPlanFragment.getPlanRoot() instanceof AggregationNode) {
AggregationNode childAgg = (AggregationNode) inputPlanFragment.getPlanRoot();
childAgg.setColocate(true);
}
}
setPlanRoot(inputPlanFragment, aggregationNode, aggregate);
if (aggregate.getStats() != null) {