[opt](Nereids) forbid one step topn with distribute as child (#40066) (#40278)

pick from master #40066
This commit is contained in:
morrySnow
2024-09-02 22:26:26 +08:00
committed by GitHub
parent a5efdc6085
commit 1527099e35

View File

@ -518,12 +518,16 @@ public class ChildrenPropertiesRegulator extends PlanVisitor<Boolean, Void> {
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;
}
// forbid one step topn with distribute as child
if (topN.getSortPhase() == SortPhase.GATHER_SORT
&& children.get(0).getPlan() instanceof PhysicalDistribute) {
return false;
}
return true;
}