This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new da8b43ed6e5 [opt](Nereids) forbid one step topn with distribute as 
child (#40066)
da8b43ed6e5 is described below

commit da8b43ed6e558249942c21b01a691144e6fa5b93
Author: morrySnow <101034200+morrys...@users.noreply.github.com>
AuthorDate: Thu Aug 29 21:31:20 2024 +0800

    [opt](Nereids) forbid one step topn with distribute as child (#40066)
---
 .../doris/nereids/properties/ChildrenPropertiesRegulator.java  | 10 ++++++++++
 1 file changed, 10 insertions(+)

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 686350ea91d..9985b9c567f 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
@@ -537,11 +537,21 @@ public class ChildrenPropertiesRegulator extends 
PlanVisitor<Boolean, Void> {
         // process must shuffle
         visit(topN, context);
 
+        int sortPhaseNum = 
jobContext.getCascadesContext().getConnectContext().getSessionVariable().sortPhaseNum;
+        // if control sort phase, forbid nothing
+        if (sortPhaseNum == 1 || sortPhaseNum == 2) {
+            return true;
+        }
         // 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;
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to