From 1527099e359b7b00bdfa8355044b6aadf15657c2 Mon Sep 17 00:00:00 2001 From: morrySnow <101034200+morrySnow@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:26:26 +0800 Subject: [PATCH] [opt](Nereids) forbid one step topn with distribute as child (#40066) (#40278) pick from master #40066 --- .../nereids/properties/ChildrenPropertiesRegulator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildrenPropertiesRegulator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildrenPropertiesRegulator.java index c83c0d3582..5ba1bd87b0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildrenPropertiesRegulator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildrenPropertiesRegulator.java @@ -518,12 +518,16 @@ public class ChildrenPropertiesRegulator extends PlanVisitor { public Boolean visitPhysicalTopN(PhysicalTopN 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; }