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

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 47716bce773 [Fix](Nereids) fix leading with multi level of brace pairs 
(#35606)
47716bce773 is described below

commit 47716bce773aa0a24fd2fc6db641a99269fbdc68
Author: LiBinfeng <46676950+libinfeng...@users.noreply.github.com>
AuthorDate: Thu May 30 15:46:03 2024 +0800

    [Fix](Nereids) fix leading with multi level of brace pairs (#35606)
    
    cherry-pick: #34169
    
    fix leading with multi level of brace pairs. example:
    leading(t1 {{t2 t3} {t4 t5}} t6)
    can be reduced to
    leading(t1 {t2 t3 {t4 t5}} t6)
    
    also update cases which remove project node from explain shape plan
---
 .../org/apache/doris/nereids/hint/LeadingHint.java |  44 +-
 .../data/nereids_p0/hint/fix_leading.out           |  36 +-
 .../data/nereids_p0/hint/test_leading.out          | 783 +++++++++++++++++++++
 .../suites/nereids_p0/hint/fix_leading.groovy      |  13 +-
 .../suites/nereids_p0/hint/test_leading.groovy     |   1 +
 5 files changed, 851 insertions(+), 26 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/hint/LeadingHint.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/hint/LeadingHint.java
index a1b1af1609b..92ff5c8bfc2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/hint/LeadingHint.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/hint/LeadingHint.java
@@ -51,7 +51,7 @@ import java.util.Stack;
 public class LeadingHint extends Hint {
     private String originalString = "";
     private final List<String> tablelist = new ArrayList<>();
-    private final List<Integer> levellist = new ArrayList<>();
+    private final List<Integer> levelList = new ArrayList<>();
 
     private final Map<RelationId, LogicalPlan> relationIdToScanMap = 
Maps.newLinkedHashMap();
 
@@ -101,18 +101,46 @@ public class LeadingHint extends Hint {
                 }
             } else {
                 tablelist.add(parameter);
-                levellist.add(level);
+                levelList.add(level);
             }
             lastParameter = parameter;
         }
+        normalizeLevelList();
+    }
+
+    private void removeGap(int left, int right, int gap) {
+        for (int i = left; i <= right; i++) {
+            levelList.set(i, levelList.get(i) - (gap - 1));
+        }
+    }
+
+    // when we write leading like: leading(t1 {{t2 t3} {t4 t5}} t6)
+    // levelList would like 0 2 2 3 3 0, it could be reduced to 0 1 1 2 2 0 
like leading(t1 {t2 t3 {t4 t5}} t6)
+    // gap is like 0 to 2 or 3 to 0 in upper example, and this function is to 
remove gap when we use a lot of braces
+    private void normalizeLevelList() {
+        int leftIndex = 0;
+        // at lease two tables were needed
+        for (int i = 1; i < levelList.size(); i++) {
+            if ((levelList.get(i) - levelList.get(leftIndex)) > 1) {
+                int rightIndex = i;
+                for (int j = i; j < levelList.size(); j++) {
+                    if ((levelList.get(rightIndex) - levelList.get(j)) > 1) {
+                        removeGap(i, rightIndex, Math.min(levelList.get(i) - 
levelList.get(leftIndex),
+                                levelList.get(rightIndex) - levelList.get(j)));
+                    }
+                    rightIndex = j;
+                }
+            }
+            leftIndex = i;
+        }
     }
 
     public List<String> getTablelist() {
         return tablelist;
     }
 
-    public List<Integer> getLevellist() {
-        return levellist;
+    public List<Integer> getLevelList() {
+        return levelList;
     }
 
     public Map<RelationId, LogicalPlan> getRelationIdToScanMap() {
@@ -450,10 +478,10 @@ public class LeadingHint extends Hint {
         }
         logicalPlan = makeFilterPlanIfExist(getFilters(), logicalPlan);
         assert (logicalPlan != null);
-        stack.push(Pair.of(getLevellist().get(index), logicalPlan));
-        int stackTopLevel = getLevellist().get(index++);
+        stack.push(Pair.of(getLevelList().get(index), logicalPlan));
+        int stackTopLevel = getLevelList().get(index++);
         while (index < getTablelist().size()) {
-            int currentLevel = getLevellist().get(index);
+            int currentLevel = getLevelList().get(index);
             if (currentLevel == stackTopLevel) {
                 // should return error if can not found table
                 logicalPlan = 
getLogicalPlanByName(getTablelist().get(index++));
@@ -492,7 +520,7 @@ public class LeadingHint extends Hint {
                     
logicalJoin.setBitmap(LongBitmap.or(getBitmap(newStackTop.second), 
getBitmap(logicalPlan)));
                     if (stackTopLevel > 0) {
                         if (index < getTablelist().size()) {
-                            if (stackTopLevel > getLevellist().get(index)) {
+                            if (stackTopLevel > getLevelList().get(index)) {
                                 stackTopLevel--;
                             }
                         } else {
diff --git a/regression-test/data/nereids_p0/hint/fix_leading.out 
b/regression-test/data/nereids_p0/hint/fix_leading.out
index feb69f97783..4a2ceae5c3f 100644
--- a/regression-test/data/nereids_p0/hint/fix_leading.out
+++ b/regression-test/data/nereids_p0/hint/fix_leading.out
@@ -251,28 +251,30 @@ Used: leading(t1 t2 t3 )
 UnUsed:
 SyntaxError:
 
--- !select5_1 --
+-- !select6_1 --
 PhysicalResultSink
 --hashAgg[GLOBAL]
 ----PhysicalDistribute[DistributionSpecGather]
 ------hashAgg[LOCAL]
---------PhysicalProject
-----------NestedLoopJoin[LEFT_OUTER_JOIN](t3.c3 > 500)
-------------PhysicalProject
---------------PhysicalOlapScan[t3]
-------------PhysicalDistribute[DistributionSpecReplicated]
---------------PhysicalProject
-----------------NestedLoopJoin[LEFT_OUTER_JOIN](t1.c1 > 500)
-------------------PhysicalProject
---------------------filter((t1.c1 < 200))
-----------------------PhysicalOlapScan[t1]
-------------------PhysicalDistribute[DistributionSpecReplicated]
---------------------PhysicalProject
-----------------------filter((t2.c2 > 500))
-------------------------PhysicalOlapScan[t2]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t6.c6)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2) and (t1.c1 = 
t3.c3) and (t1.c1 = t4.c4) and (t1.c1 = t5.c5)) otherCondition=()
+------------PhysicalOlapScan[t1]
+------------PhysicalDistribute[DistributionSpecHash]
+--------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t4.c4) and (t2.c2 = 
t5.c5) and (t3.c3 = t4.c4) and (t3.c3 = t5.c5)) otherCondition=()
+----------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) 
otherCondition=()
+------------------PhysicalOlapScan[t2]
+------------------PhysicalDistribute[DistributionSpecHash]
+--------------------PhysicalOlapScan[t3]
+----------------PhysicalDistribute[DistributionSpecHash]
+------------------hashJoin[INNER_JOIN] hashCondition=((t4.c4 = t5.c5)) 
otherCondition=()
+--------------------PhysicalOlapScan[t4]
+--------------------PhysicalDistribute[DistributionSpecHash]
+----------------------PhysicalOlapScan[t5]
+----------PhysicalDistribute[DistributionSpecHash]
+------------PhysicalOlapScan[t6]
 
 Hint log:
-Used:
+Used: leading(t1 { { t2 t3 } { t4 t5 } } t6 )
 UnUsed:
-SyntaxError: leading(t1 t2) Msg:leading should have all tables in query block, 
missing tables: t3 
+SyntaxError:
 
diff --git a/regression-test/data/nereids_p0/hint/test_leading.out 
b/regression-test/data/nereids_p0/hint/test_leading.out
index 3271c89c3b2..058fdf8b52f 100644
--- a/regression-test/data/nereids_p0/hint/test_leading.out
+++ b/regression-test/data/nereids_p0/hint/test_leading.out
@@ -2147,3 +2147,786 @@
 -- !select88_13 --
 119
 
+-- !select90_1 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
+----------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------PhysicalOlapScan[t2]
+
+Hint log:
+Used: [broadcast]_2
+UnUsed:
+SyntaxError:
+
+-- !select90_3 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+--------------PhysicalOlapScan[t1]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used: [broadcast]_2 [shuffle]_3
+UnUsed:
+SyntaxError:
+
+-- !select90_5 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t2.c2 = t3.c3)) 
otherCondition=()
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+--------------PhysicalOlapScan[t1]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used: [broadcast]_2 [shuffle]_3
+UnUsed:
+SyntaxError:
+
+-- !select92_1 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t1]
+------------PhysicalDistribute[DistributionSpecHash]
+--------------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:   leading(t1 shuffle t2 broadcast t3 )
+UnUsed:
+SyntaxError:
+
+-- !select92_2 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
+----------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t2]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:   leading(t1 shuffle { t2 broadcast t3 } )
+UnUsed:
+SyntaxError:
+
+-- !select92_3 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
+----------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t3]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t2]
+
+Hint log:
+Used:   leading(t1 shuffle { t3 broadcast t2 } )
+UnUsed:
+SyntaxError:
+
+-- !select92_4 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t2]
+------------PhysicalDistribute[DistributionSpecHash]
+--------------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:   leading(t2 shuffle t1 broadcast t3 )
+UnUsed:
+SyntaxError:
+
+-- !select92_5 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2) and (t2.c2 = 
t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t1]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:   leading(t2 shuffle { t1 broadcast t3 } )
+UnUsed:
+SyntaxError:
+
+-- !select92_6 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2) and (t2.c2 = 
t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t3]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t1]
+
+Hint log:
+Used:   leading(t2 shuffle { t3 broadcast t1 } )
+UnUsed:
+SyntaxError:
+
+-- !select93_1 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t1]
+------------PhysicalDistribute[DistributionSpecHash]
+--------------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t1 t2 broadcast t3 )
+UnUsed:
+SyntaxError:
+
+-- !select93_2 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
+----------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t2]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t1 { t2 broadcast t3 } )
+UnUsed:
+SyntaxError:
+
+-- !select93_3 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
+----------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t3]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t2]
+
+Hint log:
+Used:  leading(t1 { t3 broadcast t2 } )
+UnUsed:
+SyntaxError:
+
+-- !select93_4 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t2]
+------------PhysicalDistribute[DistributionSpecHash]
+--------------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t2 t1 broadcast t3 )
+UnUsed:
+SyntaxError:
+
+-- !select93_5 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2) and (t2.c2 = 
t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t1]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t2 { t1 broadcast t3 } )
+UnUsed:
+SyntaxError:
+
+-- !select93_6 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2) and (t2.c2 = 
t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t3]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t1]
+
+Hint log:
+Used:  leading(t2 { t3 broadcast t1 } )
+UnUsed:
+SyntaxError:
+
+-- !select94_2 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t1]
+------------PhysicalDistribute[DistributionSpecHash]
+--------------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t1 shuffle t2 t3 )
+UnUsed:
+SyntaxError:
+
+-- !select94_2 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
+----------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t2]
+--------------PhysicalDistribute[DistributionSpecHash]
+----------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t1 shuffle { t2 t3 } )
+UnUsed:
+SyntaxError:
+
+-- !select94_2 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
+----------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t3]
+--------------PhysicalDistribute[DistributionSpecHash]
+----------------PhysicalOlapScan[t2]
+
+Hint log:
+Used:  leading(t1 shuffle { t3 t2 } )
+UnUsed:
+SyntaxError:
+
+-- !select94_2 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t2]
+------------PhysicalDistribute[DistributionSpecHash]
+--------------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecHash]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t2 shuffle t1 t3 )
+UnUsed:
+SyntaxError:
+
+-- !select94_2 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2) and (t2.c2 = 
t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t1]
+--------------PhysicalDistribute[DistributionSpecHash]
+----------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t2 shuffle { t1 t3 } )
+UnUsed:
+SyntaxError:
+
+-- !select94_2 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2) and (t2.c2 = 
t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t3.c3)) 
otherCondition=()
+--------------PhysicalOlapScan[t3]
+--------------PhysicalDistribute[DistributionSpecHash]
+----------------PhysicalOlapScan[t1]
+
+Hint log:
+Used:  leading(t2 shuffle { t3 t1 } )
+UnUsed:
+SyntaxError:
+
+-- !select95_1 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t1]
+------------PhysicalDistribute[DistributionSpecReplicated]
+--------------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t1 broadcast t2 t3 )
+UnUsed:
+SyntaxError:
+
+-- !select95_4 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t2]
+------------PhysicalDistribute[DistributionSpecReplicated]
+--------------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecHash]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:  leading(t2 broadcast t1 t3 )
+UnUsed:
+SyntaxError:
+
+-- !select95_8 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t3]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+--------------PhysicalOlapScan[t1]
+--------------PhysicalDistribute[DistributionSpecHash]
+----------------PhysicalOlapScan[t2]
+
+Hint log:
+Used:  leading(t3 broadcast { t1 t2 } )
+UnUsed:
+SyntaxError:
+
+-- !select95_9 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t3]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+--------------PhysicalOlapScan[t2]
+--------------PhysicalDistribute[DistributionSpecHash]
+----------------PhysicalOlapScan[t1]
+
+Hint log:
+Used:  leading(t3 broadcast { t2 t1 } )
+UnUsed:
+SyntaxError:
+
+-- !select96_1 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t1]
+------------PhysicalDistribute[DistributionSpecHash]
+--------------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:   leading(t1 shuffle t2 broadcast t3 )
+UnUsed:
+SyntaxError:
+
+-- !select96_4 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t2]
+------------PhysicalDistribute[DistributionSpecHash]
+--------------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:   leading(t2 shuffle t1 broadcast t3 )
+UnUsed:
+SyntaxError:
+
+-- !select96_8 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t3]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+--------------PhysicalOlapScan[t1]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t2]
+
+Hint log:
+Used:   leading(t3 shuffle { t1 broadcast t2 } )
+UnUsed:
+SyntaxError:
+
+-- !select96_9 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t3]
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+--------------PhysicalOlapScan[t2]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t1]
+
+Hint log:
+Used:   leading(t3 shuffle { t2 broadcast t1 } )
+UnUsed:
+SyntaxError:
+
+-- !select97_1 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------PhysicalDistribute[DistributionSpecHash]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+--------------PhysicalOlapScan[t1]
+--------------PhysicalDistribute[DistributionSpecReplicated]
+----------------PhysicalOlapScan[t2]
+----------PhysicalDistribute[DistributionSpecHash]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:   leading(t1 broadcast t2 shuffle t3 )
+UnUsed:
+SyntaxError:
+
+-- !select97_4 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+------------PhysicalOlapScan[t2]
+------------PhysicalDistribute[DistributionSpecReplicated]
+--------------PhysicalOlapScan[t1]
+----------PhysicalDistribute[DistributionSpecHash]
+------------PhysicalOlapScan[t3]
+
+Hint log:
+Used:   leading(t2 broadcast t1 shuffle t3 )
+UnUsed:
+SyntaxError:
+
+-- !select97_8 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t3]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+--------------PhysicalOlapScan[t1]
+--------------PhysicalDistribute[DistributionSpecHash]
+----------------PhysicalOlapScan[t2]
+
+Hint log:
+Used:   leading(t3 broadcast { t1 shuffle t2 } )
+UnUsed:
+SyntaxError:
+
+-- !select97_9 --
+PhysicalResultSink
+--hashAgg[GLOBAL]
+----PhysicalDistribute[DistributionSpecGather]
+------hashAgg[LOCAL]
+--------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
+----------PhysicalOlapScan[t3]
+----------PhysicalDistribute[DistributionSpecReplicated]
+------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
+--------------PhysicalOlapScan[t2]
+--------------PhysicalDistribute[DistributionSpecHash]
+----------------PhysicalOlapScan[t1]
+
+Hint log:
+Used:   leading(t3 broadcast { t2 shuffle t1 } )
+UnUsed:
+SyntaxError:
+
+-- !select100_0 --
+1719
+
+-- !select100_1 --
+1719
+
+-- !select100_2 --
+1980
+
+-- !select100_3 --
+3103
+
+-- !select100_4 --
+3512
+
+-- !select100_5 --
+3472
+
+-- !select100_6 --
+3472
+
+-- !select101_0 --
+3103
+
+-- !select101_1 --
+3103
+
+-- !select101_2 --
+3512
+
+-- !select101_3 --
+3472
+
+-- !select101_4 --
+3472
+
+-- !select102_0 --
+3103
+
+-- !select102_1 --
+3103
+
+-- !select102_2 --
+3103
+
+-- !select102_3 --
+3103
+
+-- !select102_4 --
+3103
+
+-- !select102_5 --
+3103
+
+-- !select102_6 --
+3103
+
+-- !select103_0 --
+3103
+
+-- !select103_1 --
+3103
+
+-- !select103_2 --
+3103
+
+-- !select103_3 --
+3103
+
+-- !select103_4 --
+3103
+
+-- !select103_5 --
+3103
+
+-- !select103_6 --
+3103
+
+-- !select104_0 --
+3103
+
+-- !select104_1 --
+3103
+
+-- !select104_2 --
+3103
+
+-- !select104_3 --
+3103
+
+-- !select104_4 --
+3103
+
+-- !select104_5 --
+3103
+
+-- !select104_6 --
+3103
+
+-- !select105_0 --
+3103
+
+-- !select105_1 --
+3103
+
+-- !select105_2 --
+3103
+
+-- !select105_3 --
+3103
+
+-- !select105_4 --
+3103
+
+-- !select105_5 --
+3103
+
+-- !select105_6 --
+3103
+
+-- !select105_7 --
+3103
+
+-- !select105_8 --
+3103
+
+-- !select105_9 --
+3103
+
+-- !select106_0 --
+3103
+
+-- !select106_1 --
+3103
+
+-- !select106_2 --
+3103
+
+-- !select106_3 --
+3103
+
+-- !select106_4 --
+3103
+
+-- !select106_5 --
+3103
+
+-- !select106_6 --
+3103
+
+-- !select106_7 --
+3103
+
+-- !select106_8 --
+3103
+
+-- !select106_9 --
+3103
+
+-- !select107_0 --
+3103
+
+-- !select107_1 --
+3103
+
+-- !select107_2 --
+3103
+
+-- !select107_3 --
+3103
+
+-- !select107_4 --
+3103
+
+-- !select107_5 --
+3103
+
+-- !select107_6 --
+3103
+
+-- !select107_7 --
+3103
+
+-- !select107_8 --
+3103
+
+-- !select107_9 --
+3103
+
diff --git a/regression-test/suites/nereids_p0/hint/fix_leading.groovy 
b/regression-test/suites/nereids_p0/hint/fix_leading.groovy
index b57cb5cc59a..80d8fb72220 100644
--- a/regression-test/suites/nereids_p0/hint/fix_leading.groovy
+++ b/regression-test/suites/nereids_p0/hint/fix_leading.groovy
@@ -26,6 +26,9 @@ suite("fix_leading") {
     // setting planner to nereids
     sql 'set enable_nereids_planner=true'
     sql 'set enable_fallback_to_original_planner=false'
+    sql 'set runtime_filter_mode=OFF'
+    sql "set ignore_shape_nodes='PhysicalProject'"
+
 
     // create tables
     sql """drop table if exists t1;"""
@@ -37,6 +40,8 @@ suite("fix_leading") {
     sql """create table t2 (c2 int, c22 int) distributed by hash(c2) buckets 3 
properties('replication_num' = '1');"""
     sql """create table t3 (c3 int, c33 int) distributed by hash(c3) buckets 3 
properties('replication_num' = '1');"""
     sql """create table t4 (c4 int, c44 int) distributed by hash(c4) buckets 3 
properties('replication_num' = '1');"""
+    sql """create table t5 (c5 int, c55 int) distributed by hash(c5) buckets 3 
properties('replication_num' = '1');"""
+    sql """create table t6 (c6 int, c66 int) distributed by hash(c6) buckets 3 
properties('replication_num' = '1');"""
 
     streamLoad {
         table "t1"
@@ -187,7 +192,13 @@ suite("fix_leading") {
     qt_select4_3 """explain shape plan select /*+ leading(t1 t2 t3)*/ count(*) 
from t1 left join t2 on c1 > 500 and c2 >500 right join t3 on c3 > 500 and c1 < 
200;"""
 
     // check whether we have all tables
-    qt_select5_1 """explain shape plan select /*+ leading(t1 t2)*/ count(*) 
from t1 left join t2 on c1 > 500 and c2 >500 right join t3 on c3 > 500 and c1 < 
200;"""
+    explain {
+        sql """shape plan select /*+ leading(t1 t2)*/ count(*) from t1 left 
join t2 on c1 > 500 and c2 >500 right join t3 on c3 > 500 and c1 < 200;"""
+        contains("SyntaxError: leading(t1 t2) Msg:leading should have all 
tables in query block, missing tables: t3")
+    }
+
+    // check brace problem
+    qt_select6_1 """explain shape plan select /*+ leading(t1 {{t2 t3}{t4 t5}} 
t6) */ count(*) from t1 join t2 on c1 = c2 join t3 on c1 = c3 join t4 on c1 = 
c4 join t5 on c1 = c5 join t6 on c1 = c6;"""
 
     // check brace problem
     qt_select6_1 """explain shape plan select /*+ leading(t1 {{t2 t3}{t4 t5}} 
t6) */ count(*) from t1 join t2 on c1 = c2 join t3 on c1 = c3 join t4 on c1 = 
c4 join t5 on c1 = c5 join t6 on c1 = c6;"""
diff --git a/regression-test/suites/nereids_p0/hint/test_leading.groovy 
b/regression-test/suites/nereids_p0/hint/test_leading.groovy
index e2227cc357f..8f0ecbc014b 100644
--- a/regression-test/suites/nereids_p0/hint/test_leading.groovy
+++ b/regression-test/suites/nereids_p0/hint/test_leading.groovy
@@ -25,6 +25,7 @@ suite("test_leading") {
 
     // setting planner to nereids
     sql 'set enable_nereids_planner=true'
+    sql "set ignore_shape_nodes='PhysicalProject'"
     sql 'set enable_fallback_to_original_planner=false'
 
     // create tables


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

Reply via email to