[Fix](Nereids) TopN should forbid two-phase topN if child is DistributionSpecGather (#36877) (#38164)

pick from master #36877
This commit is contained in:
Jensen
2024-07-23 16:27:55 +08:00
committed by GitHub
parent ba5d23aea8
commit ca7d8325af
41 changed files with 1333 additions and 1370 deletions

View File

@ -42,6 +42,7 @@ import org.apache.doris.nereids.trees.plans.physical.PhysicalNestedLoopJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalPartitionTopN;
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
import org.apache.doris.nereids.trees.plans.physical.PhysicalSetOperation;
import org.apache.doris.nereids.trees.plans.physical.PhysicalTopN;
import org.apache.doris.nereids.trees.plans.physical.PhysicalUnion;
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.nereids.util.JoinUtils;
@ -464,6 +465,19 @@ public class ChildrenPropertiesRegulator extends PlanVisitor<Boolean, Void> {
return true;
}
@Override
public Boolean visitPhysicalTopN(PhysicalTopN<? extends Plan> topN, Void context) {
// process must shuffle
visit(topN, context);
// If child is DistributionSpecGather, topN should forbid two-phase topN
if (topN.getSortPhase() == SortPhase.LOCAL_SORT
&& childrenProperties.get(0).getDistributionSpec().equals(DistributionSpecGather.INSTANCE)) {
return false;
}
return true;
}
/**
* check both side real output hash key order are same or not.
*