[Fix](Nereids) TopN should forbid two-phase topN if child is DistributionSpecGather (#36877) (#38164)
pick from master #36877
This commit is contained in:
@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user