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 1813ec26a22 [fix](Nereids) fix leading tag can not work when leading 
is used (#40958)
1813ec26a22 is described below

commit 1813ec26a2273f0a5ae56e1576762ea743e0ebe6
Author: LiBinfeng <[email protected]>
AuthorDate: Mon Oct 14 11:10:15 2024 +0800

    [fix](Nereids) fix leading tag can not work when leading is used (#40958)
    
    isLeading in cascade context means do we have leading in this scope
    isLeadingDisableJoinReorder means does leading used
    we need to copy it after analyze outerside of cte
---
 .../org/apache/doris/nereids/CascadesContext.java  |  16 +--
 .../doris/nereids/rules/analysis/AnalyzeCTE.java   |   1 +
 .../nereids/rules/analysis/AnalyzeCTETest.java     |  14 +++
 .../data/nereids_hint_tpcds_p0/shape/query64.out   |   4 +-
 .../data/nereids_hint_tpcds_p0/shape/query81.out   |   6 +-
 .../data/nereids_p0/hint/multi_leading.out         |  94 +++++++-------
 regression-test/data/nereids_p0/hint/test_hint.out |  12 +-
 .../suites/nereids_p0/hint/multi_leading.groovy    | 138 ++++++++++-----------
 .../suites/nereids_p0/hint/test_hint.groovy        |  16 +--
 9 files changed, 159 insertions(+), 142 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/CascadesContext.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/CascadesContext.java
index 25767134d4d..a5c966370f0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/CascadesContext.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/CascadesContext.java
@@ -147,7 +147,7 @@ public class CascadesContext implements ScheduleContext {
      */
     private CascadesContext(Optional<CascadesContext> parent, Optional<CTEId> 
currentTree,
             StatementContext statementContext, Plan plan, Memo memo,
-            CTEContext cteContext, PhysicalProperties requireProperties) {
+            CTEContext cteContext, PhysicalProperties requireProperties, 
boolean isLeadingDisableJoinReorder) {
         this.parent = Objects.requireNonNull(parent, "parent should not null");
         this.currentTree = Objects.requireNonNull(currentTree, "currentTree 
should not null");
         this.statementContext = Objects.requireNonNull(statementContext, 
"statementContext should not null");
@@ -171,6 +171,7 @@ public class CascadesContext implements ScheduleContext {
         if (parent.isPresent()) {
             this.tables = parent.get().tables;
         }
+        this.isLeadingDisableJoinReorder = isLeadingDisableJoinReorder;
     }
 
     /**
@@ -179,7 +180,7 @@ public class CascadesContext implements ScheduleContext {
     public static CascadesContext initContext(StatementContext 
statementContext,
             Plan initPlan, PhysicalProperties requireProperties) {
         return newContext(Optional.empty(), Optional.empty(), statementContext,
-                initPlan, new CTEContext(), requireProperties);
+                initPlan, new CTEContext(), requireProperties, false);
     }
 
     /**
@@ -188,14 +189,15 @@ public class CascadesContext implements ScheduleContext {
     public static CascadesContext newContextWithCteContext(CascadesContext 
cascadesContext,
             Plan initPlan, CTEContext cteContext) {
         return newContext(Optional.of(cascadesContext), Optional.empty(),
-                cascadesContext.getStatementContext(), initPlan, cteContext, 
PhysicalProperties.ANY
+                cascadesContext.getStatementContext(), initPlan, cteContext, 
PhysicalProperties.ANY,
+                cascadesContext.isLeadingDisableJoinReorder
         );
     }
 
     public static CascadesContext newCurrentTreeContext(CascadesContext 
context) {
         return CascadesContext.newContext(context.getParent(), 
context.getCurrentTree(), context.getStatementContext(),
                 context.getRewritePlan(), context.getCteContext(),
-                context.getCurrentJobContext().getRequiredProperties());
+                context.getCurrentJobContext().getRequiredProperties(), 
context.isLeadingDisableJoinReorder);
     }
 
     /**
@@ -204,14 +206,14 @@ public class CascadesContext implements ScheduleContext {
     public static CascadesContext newSubtreeContext(Optional<CTEId> subtree, 
CascadesContext context,
             Plan plan, PhysicalProperties requireProperties) {
         return CascadesContext.newContext(Optional.of(context), subtree, 
context.getStatementContext(),
-                plan, context.getCteContext(), requireProperties);
+                plan, context.getCteContext(), requireProperties, 
context.isLeadingDisableJoinReorder);
     }
 
     private static CascadesContext newContext(Optional<CascadesContext> 
parent, Optional<CTEId> subtree,
             StatementContext statementContext, Plan initPlan, CTEContext 
cteContext,
-            PhysicalProperties requireProperties) {
+            PhysicalProperties requireProperties, boolean 
isLeadingDisableJoinReorder) {
         return new CascadesContext(parent, subtree, statementContext, 
initPlan, null,
-            cteContext, requireProperties);
+            cteContext, requireProperties, isLeadingDisableJoinReorder);
     }
 
     public CascadesContext getRoot() {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTE.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTE.java
index 0fe083c1e93..129b0860a74 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTE.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTE.java
@@ -72,6 +72,7 @@ public class AnalyzeCTE extends OneAnalysisRuleFactory {
             CascadesContext outerCascadesCtx = 
CascadesContext.newContextWithCteContext(
                     ctx.cascadesContext, logicalCTE.child(), result.first);
             outerCascadesCtx.newAnalyzer().analyze();
+            
ctx.cascadesContext.setLeadingDisableJoinReorder(outerCascadesCtx.isLeadingDisableJoinReorder());
             Plan root = outerCascadesCtx.getRewritePlan();
             // should construct anchor from back to front, because the cte 
behind depends on the front
             for (int i = result.second.size() - 1; i >= 0; i--) {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTETest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTETest.java
index abe82c858d4..a91c0dd4712 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTETest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTETest.java
@@ -68,6 +68,11 @@ public class AnalyzeCTETest extends TestWithFeService 
implements MemoPatternMatc
             + "cte2 AS (SELECT sk FROM cte1 WHERE sk < 3)"
             + "SELECT * FROM cte1 JOIN cte2 ON cte1.sk = cte2.sk";
 
+    private final String cteLeadingJoin = "WITH cte1 AS (SELECT /*+ 
leading(supplier customer) */ s_suppkey AS sk "
+            + "FROM supplier join customer on c_nation = s_nation), "
+            + "cte2 AS (SELECT sk FROM cte1 WHERE sk < 3)"
+            + "SELECT /*+ leading(cte2 cte1) */ * FROM cte1 JOIN cte2 ON 
cte1.sk = cte2.sk";
+
     private final String cteReferToAnotherOne = "WITH V1 AS (SELECT s_suppkey 
FROM supplier), "
             + "V2 AS (SELECT s_suppkey FROM V1)"
             + "SELECT * FROM V2";
@@ -128,6 +133,15 @@ public class AnalyzeCTETest extends TestWithFeService 
implements MemoPatternMatc
         }
     }
 
+    @Test
+    public void testLeadingCte() throws Exception {
+        StatementScopeIdGenerator.clear();
+        StatementContext statementContext = 
MemoTestUtils.createStatementContext(connectContext, cteLeadingJoin);
+        NereidsPlanner planner = new NereidsPlanner(statementContext);
+        planner.planWithLock(parser.parseSingle(cteLeadingJoin), 
PhysicalProperties.ANY);
+        
Assertions.assertTrue(planner.getCascadesContext().isLeadingDisableJoinReorder());
+    }
+
     @Test
     public void testCTEInHavingAndSubquery() {
 
diff --git a/regression-test/data/nereids_hint_tpcds_p0/shape/query64.out 
b/regression-test/data/nereids_hint_tpcds_p0/shape/query64.out
index 1ced65fe98f..1338812312e 100644
--- a/regression-test/data/nereids_hint_tpcds_p0/shape/query64.out
+++ b/regression-test/data/nereids_hint_tpcds_p0/shape/query64.out
@@ -99,7 +99,7 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
 ------------------PhysicalCteConsumer ( cteId=CTEId#1 )
 
 Hint log:
-Used: leading(catalog_sales catalog_returns ) leading({ store_sales { { 
customer d2 } cd2 } } cd1 d3 item { hd1 ib1 } store_returns ad1 hd2 ad2 ib2 d1 
store promotion cs_ui ) leading(cs1 cs2 )
-UnUsed:  
+Used: leading(catalog_sales shuffle catalog_returns )  leading({ store_sales { 
{ customer d2 } cd2 } } cd1 d3 item { hd1 ib1 } store_returns ad1 hd2 ad2 ib2 
d1 store promotion cs_ui ) leading(cs1 shuffle cs2 )
+UnUsed: 
 SyntaxError:
 
diff --git a/regression-test/data/nereids_hint_tpcds_p0/shape/query81.out 
b/regression-test/data/nereids_hint_tpcds_p0/shape/query81.out
index 465ebcbaaaf..fcbe4a8ad57 100644
--- a/regression-test/data/nereids_hint_tpcds_p0/shape/query81.out
+++ b/regression-test/data/nereids_hint_tpcds_p0/shape/query81.out
@@ -24,15 +24,15 @@ PhysicalCteAnchor ( cteId=CTEId#0 )
 ----------PhysicalProject
 ------------hashJoin[INNER_JOIN broadcast] hashCondition=((ctr1.ctr_state = 
ctr2.ctr_state)) otherCondition=((cast(ctr_total_return as DOUBLE) > 
cast((avg(cast(ctr_total_return as DECIMALV3(38, 4))) * 1.2) as DOUBLE))) build 
RFs:RF4 ctr_state->[ctr_state]
 --------------PhysicalProject
-----------------hashJoin[INNER_JOIN shuffle] 
hashCondition=((ctr1.ctr_customer_sk = customer.c_customer_sk)) 
otherCondition=() build RFs:RF3 c_customer_sk->[ctr_customer_sk]
-------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4
+----------------hashJoin[INNER_JOIN shuffle] 
hashCondition=((ctr1.ctr_customer_sk = customer.c_customer_sk)) 
otherCondition=() build RFs:RF3 ctr_customer_sk->[c_customer_sk]
 ------------------PhysicalProject
 --------------------hashJoin[INNER_JOIN broadcast] 
hashCondition=((customer_address.ca_address_sk = customer.c_current_addr_sk)) 
otherCondition=() build RFs:RF2 ca_address_sk->[c_current_addr_sk]
 ----------------------PhysicalProject
-------------------------PhysicalOlapScan[customer] apply RFs: RF2
+------------------------PhysicalOlapScan[customer] apply RFs: RF2 RF3
 ----------------------PhysicalProject
 ------------------------filter((customer_address.ca_state = 'TN'))
 --------------------------PhysicalOlapScan[customer_address]
+------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4
 --------------hashAgg[GLOBAL]
 ----------------PhysicalDistribute[DistributionSpecHash]
 ------------------hashAgg[LOCAL]
diff --git a/regression-test/data/nereids_p0/hint/multi_leading.out 
b/regression-test/data/nereids_p0/hint/multi_leading.out
index ce74020695d..08b6b83ed58 100644
--- a/regression-test/data/nereids_p0/hint/multi_leading.out
+++ b/regression-test/data/nereids_p0/hint/multi_leading.out
@@ -24,17 +24,17 @@ PhysicalResultSink
 ----PhysicalDistribute[DistributionSpecGather]
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN colocated] hashCondition=((cte.c1 = t1.c1)) 
otherCondition=()
+----------filter((t1.c1 > 300))
+------------PhysicalOlapScan[t1]
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((cte.c1 = t2.c2)) 
otherCondition=()
 ------------filter((cte.c1 > 300))
 --------------PhysicalOlapScan[t1]
 ------------filter((t2.c2 > 300))
 --------------PhysicalOlapScan[t2]
-----------filter((t1.c1 > 300))
-------------PhysicalOlapScan[t1]
 
 Hint log:
-Used:
-UnUsed: leading(t1 t2) leading(t1 cte)
+Used: leading(t1 t2 ) leading(t1 cte )
+UnUsed: 
 SyntaxError:
 
 -- !sql1_4 --
@@ -43,17 +43,17 @@ PhysicalResultSink
 ----PhysicalDistribute[DistributionSpecGather]
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN colocated] hashCondition=((cte.c1 = t1.c1)) 
otherCondition=()
+----------filter((t1.c1 > 300))
+------------PhysicalOlapScan[t1]
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((cte.c1 = t2.c2)) 
otherCondition=()
 ------------filter((cte.c1 > 300))
 --------------PhysicalOlapScan[t1]
 ------------filter((t2.c2 > 300))
 --------------PhysicalOlapScan[t2]
-----------filter((t1.c1 > 300))
-------------PhysicalOlapScan[t1]
 
 Hint log:
-Used:
-UnUsed: leading(t1 t2) leading(t1 cte)
+Used: leading(t1 t2 ) leading(t1 cte )
+UnUsed: 
 SyntaxError:
 
 -- !sql1_res_1 --
@@ -74,14 +74,14 @@ PhysicalResultSink
 ----PhysicalDistribute[DistributionSpecGather]
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t3.c3)) 
otherCondition=()
+----------PhysicalOlapScan[t3]
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
 ------------PhysicalOlapScan[t1]
 ------------PhysicalOlapScan[t2]
-----------PhysicalOlapScan[t3]
 
 Hint log:
-Used:
-UnUsed: leading(t3 alias1)
+Used: leading(t3 alias1 )
+UnUsed: 
 SyntaxError:
 
 -- !sql2_3 --
@@ -91,13 +91,13 @@ PhysicalResultSink
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t3.c3)) 
otherCondition=()
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t2.c2)) 
otherCondition=()
-------------PhysicalOlapScan[t1]
 ------------PhysicalOlapScan[t2]
+------------PhysicalOlapScan[t1]
 ----------PhysicalOlapScan[t3]
 
 Hint log:
-Used:
-UnUsed: leading(t2 t1)
+Used: leading(t2 t1 )
+UnUsed: 
 SyntaxError:
 
 -- !sql2_4 --
@@ -106,14 +106,14 @@ PhysicalResultSink
 ----PhysicalDistribute[DistributionSpecGather]
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t3.c3)) 
otherCondition=()
+----------PhysicalOlapScan[t3]
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t2.c2)) 
otherCondition=()
-------------PhysicalOlapScan[t1]
 ------------PhysicalOlapScan[t2]
-----------PhysicalOlapScan[t3]
+------------PhysicalOlapScan[t1]
 
 Hint log:
-Used:
-UnUsed: leading(t2 t1) leading(t3 alias1)
+Used: leading(t2 t1 ) leading(t3 alias1 )
+UnUsed: 
 SyntaxError:
 
 -- !sql2_res_1 --
@@ -135,17 +135,17 @@ PhysicalResultSink
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = cte.c11)) 
otherCondition=()
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t3.c3)) 
otherCondition=()
+------------PhysicalOlapScan[t3]
 ------------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
 --------------PhysicalOlapScan[t1]
 --------------PhysicalOlapScan[t2]
-------------PhysicalOlapScan[t3]
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((cte.c1 = t2.c2)) 
otherCondition=()
-------------PhysicalOlapScan[t1]
 ------------PhysicalOlapScan[t2]
+------------PhysicalOlapScan[t1]
 
 Hint log:
-Used:
-UnUsed: leading(t2 t1) leading(t3 alias1 cte)
+Used: leading(t2 t1 ) leading(t3 alias1 cte )
+UnUsed: 
 SyntaxError:
 
 -- !sql3_3 --
@@ -156,16 +156,16 @@ PhysicalResultSink
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = cte.c11)) 
otherCondition=()
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t3.c3)) 
otherCondition=()
 ------------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t2.c2)) 
otherCondition=()
---------------PhysicalOlapScan[t1]
 --------------PhysicalOlapScan[t2]
+--------------PhysicalOlapScan[t1]
 ------------PhysicalOlapScan[t3]
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((cte.c1 = t2.c2)) 
otherCondition=()
 ------------PhysicalOlapScan[t1]
 ------------PhysicalOlapScan[t2]
 
 Hint log:
-Used:
-UnUsed: leading(t2 t1)
+Used: leading(t2 t1 )
+UnUsed: 
 SyntaxError:
 
 -- !sql3_4 --
@@ -175,17 +175,17 @@ PhysicalResultSink
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = cte.c11)) 
otherCondition=()
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t3.c3)) 
otherCondition=()
+------------PhysicalOlapScan[t3]
 ------------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t2.c2)) 
otherCondition=()
---------------PhysicalOlapScan[t1]
 --------------PhysicalOlapScan[t2]
-------------PhysicalOlapScan[t3]
+--------------PhysicalOlapScan[t1]
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((cte.c1 = t2.c2)) 
otherCondition=()
-------------PhysicalOlapScan[t1]
 ------------PhysicalOlapScan[t2]
+------------PhysicalOlapScan[t1]
 
 Hint log:
-Used:
-UnUsed: leading(t2 t1) leading(t2 t1) leading(t3 alias1 cte)
+Used: leading(t2 t1 ) leading(t2 t1 ) leading(t3 alias1 cte )
+UnUsed: 
 SyntaxError:
 
 -- !sql3_res_1 --
@@ -206,16 +206,16 @@ PhysicalResultSink
 ----PhysicalDistribute[DistributionSpecGather]
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t3.c3)) 
otherCondition=()
+----------PhysicalOlapScan[t3]
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = alias2.c2)) 
otherCondition=()
 ------------PhysicalOlapScan[t1]
 ------------hashJoin[INNER_JOIN broadcast] hashCondition=((t2.c2 = t4.c4)) 
otherCondition=()
 --------------PhysicalOlapScan[t2]
 --------------PhysicalOlapScan[t4]
-----------PhysicalOlapScan[t3]
 
 Hint log:
-Used:
-UnUsed: leading(t3 alias1)
+Used: leading(t3 alias1 )
+UnUsed: 
 SyntaxError:
 
 -- !sql4_2 --
@@ -225,15 +225,15 @@ PhysicalResultSink
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t3.c3)) 
otherCondition=()
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = 
alias2.c2)) otherCondition=()
-------------PhysicalOlapScan[t1]
 ------------hashJoin[INNER_JOIN broadcast] hashCondition=((t2.c2 = t4.c4)) 
otherCondition=()
 --------------PhysicalOlapScan[t2]
 --------------PhysicalOlapScan[t4]
+------------PhysicalOlapScan[t1]
 ----------PhysicalOlapScan[t3]
 
 Hint log:
-Used:
-UnUsed: leading(alias2 t1)
+Used: leading(alias2 t1 )
+UnUsed: 
 SyntaxError:
 
 -- !sql4_3 --
@@ -245,13 +245,13 @@ PhysicalResultSink
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = alias2.c2)) 
otherCondition=()
 ------------PhysicalOlapScan[t1]
 ------------hashJoin[INNER_JOIN broadcast] hashCondition=((t2.c2 = t4.c4)) 
otherCondition=()
---------------PhysicalOlapScan[t2]
 --------------PhysicalOlapScan[t4]
+--------------PhysicalOlapScan[t2]
 ----------PhysicalOlapScan[t3]
 
 Hint log:
-Used:
-UnUsed: leading(t4 t2)
+Used: leading(t4 t2 )
+UnUsed: 
 SyntaxError:
 
 -- !sql4_4 --
@@ -260,16 +260,16 @@ PhysicalResultSink
 ----PhysicalDistribute[DistributionSpecGather]
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = t3.c3)) 
otherCondition=()
+----------PhysicalOlapScan[t3]
 ----------hashJoin[INNER_JOIN broadcast] hashCondition=((alias1.c1 = 
alias2.c2)) otherCondition=()
-------------PhysicalOlapScan[t1]
 ------------hashJoin[INNER_JOIN broadcast] hashCondition=((t2.c2 = t4.c4)) 
otherCondition=()
 --------------PhysicalOlapScan[t2]
 --------------PhysicalOlapScan[t4]
-----------PhysicalOlapScan[t3]
+------------PhysicalOlapScan[t1]
 
 Hint log:
-Used:
-UnUsed: leading(alias2 t1) leading(t3 alias1)
+Used: leading(alias2 t1 ) leading(t3 alias1 )
+UnUsed: 
 SyntaxError:
 
 -- !sql4_res_0 --
@@ -311,12 +311,12 @@ PhysicalCteAnchor ( cteId=CTEId#0 )
 --------hashAgg[GLOBAL]
 ----------PhysicalDistribute[DistributionSpecGather]
 ------------hashAgg[LOCAL]
---------------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = cte.c11)) 
otherCondition=()
-----------------PhysicalOlapScan[t1]
+--------------hashJoin[INNER_JOIN shuffle] hashCondition=((t1.c1 = cte.c11)) 
otherCondition=()
 ----------------PhysicalCteConsumer ( cteId=CTEId#0 )
+----------------PhysicalOlapScan[t1]
 
 Hint log:
-Used:
-UnUsed: leading(cte t1)
+Used: leading(cte t1 )
+UnUsed: 
 SyntaxError:
 
diff --git a/regression-test/data/nereids_p0/hint/test_hint.out 
b/regression-test/data/nereids_p0/hint/test_hint.out
index f7128e7d15c..66a218b09fe 100644
--- a/regression-test/data/nereids_p0/hint/test_hint.out
+++ b/regression-test/data/nereids_p0/hint/test_hint.out
@@ -40,12 +40,12 @@ PhysicalResultSink
 ----PhysicalDistribute[DistributionSpecGather]
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
-----------PhysicalOlapScan[t1]
 ----------PhysicalOlapScan[t2]
+----------PhysicalOlapScan[t1]
 
 Hint log:
-Used:
-UnUsed: leading(t2 broadcast t1)
+Used: leading(t2 broadcast t1 ) 
+UnUsed:
 SyntaxError:
 
 -- !select1_6 --
@@ -54,12 +54,12 @@ PhysicalResultSink
 ----PhysicalDistribute[DistributionSpecGather]
 ------hashAgg[LOCAL]
 --------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = t2.c2)) 
otherCondition=()
-----------PhysicalOlapScan[t1]
 ----------PhysicalOlapScan[t2]
+----------PhysicalOlapScan[t1]
 
 Hint log:
-Used:
-UnUsed: leading(t2 broadcast t1)
+Used: leading(t2 broadcast t1 ) 
+UnUsed:
 SyntaxError:
 
 -- !select1_7 --
diff --git a/regression-test/suites/nereids_p0/hint/multi_leading.groovy 
b/regression-test/suites/nereids_p0/hint/multi_leading.groovy
index 4425fae1db2..1b7479fdd58 100644
--- a/regression-test/suites/nereids_p0/hint/multi_leading.groovy
+++ b/regression-test/suites/nereids_p0/hint/multi_leading.groovy
@@ -45,77 +45,77 @@ suite("multi_leading") {
     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');"""
 
-    // streamLoad {
-    //     table "t1"
-    //     db "test_multi_leading"
-    //     set 'column_separator', '|'
-    //     set 'format', 'csv'
-    //     file 't1.csv'
-    //     time 10000
-    // }
-
-    // streamLoad {
-    //     table "t2"
-    //     db "test_multi_leading"
-    //     set 'column_separator', '|'
-    //     set 'format', 'csv'
-    //     file 't2.csv'
-    //     time 10000
-    // }
-
-    // streamLoad {
-    //     table "t3"
-    //     db "test_multi_leading"
-    //     set 'column_separator', '|'
-    //     set 'format', 'csv'
-    //     file 't3.csv'
-    //     time 10000
-    // }
-
-    // streamLoad {
-    //     table "t4"
-    //     db "test_multi_leading"
-    //     set 'column_separator', '|'
-    //     set 'format', 'csv'
-    //     file 't4.csv'
-    //     time 10000
-    // }
+     streamLoad {
+         table "t1"
+         db "test_multi_leading"
+         set 'column_separator', '|'
+         set 'format', 'csv'
+         file 't1.csv'
+         time 10000
+     }
+
+     streamLoad {
+         table "t2"
+         db "test_multi_leading"
+         set 'column_separator', '|'
+         set 'format', 'csv'
+         file 't2.csv'
+         time 10000
+     }
+
+     streamLoad {
+         table "t3"
+         db "test_multi_leading"
+         set 'column_separator', '|'
+         set 'format', 'csv'
+         file 't3.csv'
+         time 10000
+     }
+
+     streamLoad {
+         table "t4"
+         db "test_multi_leading"
+         set 'column_separator', '|'
+         set 'format', 'csv'
+         file 't4.csv'
+         time 10000
+     }
 
     // test cte inline
-    // qt_sql1_2 """explain shape plan with cte as (select /*+ leading(t2 t1) 
*/ c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) 
from cte,t1 where cte.c1 = t1.c1 and t1.c1 > 300;"""
-    // qt_sql1_3 """explain shape plan with cte as (select /*+ leading(t1 t2) 
*/ c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) 
from cte,t1 where cte.c1 = t1.c1 and t1.c1 > 300;"""
-    // qt_sql1_4 """explain shape plan with cte as (select /*+ leading(t1 t2) 
*/ c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) 
from cte,t1 where cte.c1 = t1.c1 and t1.c1 > 300;"""
+    qt_sql1_2 """explain shape plan with cte as (select /*+ leading(t2 t1) */ 
c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) from 
cte,t1 where cte.c1 = t1.c1 and t1.c1 > 300;"""
+    qt_sql1_3 """explain shape plan with cte as (select /*+ leading(t1 t2) */ 
c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) from 
cte,t1 where cte.c1 = t1.c1 and t1.c1 > 300;"""
+    qt_sql1_4 """explain shape plan with cte as (select /*+ leading(t1 t2) */ 
c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) from 
cte,t1 where cte.c1 = t1.c1 and t1.c1 > 300;"""
 
-    // qt_sql1_res_1 """with cte as (select c11, c1 from t1 join t2 on c1 = 
c2) select count(*) from cte,t1 where cte.c1 = t1.c1 and t1.c1 > 300;"""
-    // qt_sql1_res_2 """with cte as (select /*+ leading(t2 t1) */ c11, c1 from 
t1 join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) from cte,t1 where 
cte.c1 = t1.c1 and t1.c1 > 300;"""
-    // qt_sql1_res_3 """with cte as (select /*+ leading(t1 t2) */ c11, c1 from 
t1 join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) from cte,t1 where 
cte.c1 = t1.c1 and t1.c1 > 300;"""
-    // qt_sql1_res_4 """with cte as (select /*+ leading(t1 t2) */ c11, c1 from 
t1 join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) from cte,t1 where 
cte.c1 = t1.c1 and t1.c1 > 300;"""
+    qt_sql1_res_1 """with cte as (select c11, c1 from t1 join t2 on c1 = c2) 
select count(*) from cte,t1 where cte.c1 = t1.c1 and t1.c1 > 300;"""
+    qt_sql1_res_2 """with cte as (select /*+ leading(t2 t1) */ c11, c1 from t1 
join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) from cte,t1 where 
cte.c1 = t1.c1 and t1.c1 > 300;"""
+    qt_sql1_res_3 """with cte as (select /*+ leading(t1 t2) */ c11, c1 from t1 
join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) from cte,t1 where 
cte.c1 = t1.c1 and t1.c1 > 300;"""
+    qt_sql1_res_4 """with cte as (select /*+ leading(t1 t2) */ c11, c1 from t1 
join t2 on c1 = c2) select /*+ leading(t1 cte)*/ count(*) from cte,t1 where 
cte.c1 = t1.c1 and t1.c1 > 300;"""
 
     // // test subquery alone
-    // qt_sql2_2 """explain shape plan select /*+ leading(t3 alias1) */ 
count(*) from (select c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on 
alias1.c1 = t3.c3;"""
-    // qt_sql2_3 """explain shape plan select count(*) from (select /*+ 
leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on 
alias1.c1 = t3.c3;"""
-    // qt_sql2_4 """explain shape plan select /*+ leading(t3 alias1) */ 
count(*) from (select /*+ leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) 
as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql2_2 """explain shape plan select /*+ leading(t3 alias1) */ count(*) 
from (select c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on alias1.c1 
= t3.c3;"""
+    qt_sql2_3 """explain shape plan select count(*) from (select /*+ 
leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on 
alias1.c1 = t3.c3;"""
+    qt_sql2_4 """explain shape plan select /*+ leading(t3 alias1) */ count(*) 
from (select /*+ leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) as 
alias1 join t3 on alias1.c1 = t3.c3;"""
 
-    // qt_sql2_res_1 """select count(*) from (select c1, c11 from t1 join t2 
on c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql2_res_2 """select /*+ leading(t3 alias1) */ count(*) from (select 
c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql2_res_3 """select count(*) from (select /*+ leading(t2 t1) */ c1, 
c11 from t1 join t2 on c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql2_res_4 """select /*+ leading(t3 alias1) */ count(*) from (select 
/*+ leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on 
alias1.c1 = t3.c3;"""
+    qt_sql2_res_1 """select count(*) from (select c1, c11 from t1 join t2 on 
c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql2_res_2 """select /*+ leading(t3 alias1) */ count(*) from (select 
c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql2_res_3 """select count(*) from (select /*+ leading(t2 t1) */ c1, 
c11 from t1 join t2 on c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql2_res_4 """select /*+ leading(t3 alias1) */ count(*) from (select 
/*+ leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on 
alias1.c1 = t3.c3;"""
 
     // // test subquery + cte
-    // qt_sql3_2 """explain shape plan with cte as (select /*+ leading(t2 t1) 
*/ c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t3 alias1 cte) */ 
count(*) from (select c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on 
alias1.c1 = t3.c3 join cte on alias1.c1 = cte.c11;;"""
-    // qt_sql3_3 """explain shape plan with cte as (select c11, c1 from t1 
join t2 on c1 = c2) select count(*) from (select /*+ leading(t2 t1) */ c1, c11 
from t1 join t2 on c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3 join cte on 
alias1.c1 = cte.c11;;"""
-    // qt_sql3_4 """explain shape plan with cte as (select /*+ leading(t2 t1) 
*/ c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t3 alias1 cte) */ 
count(*) from (select /*+ leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) 
as alias1 join t3 on alias1.c1 = t3.c3 join cte on alias1.c1 = cte.c11;;"""
+    qt_sql3_2 """explain shape plan with cte as (select /*+ leading(t2 t1) */ 
c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t3 alias1 cte) */ 
count(*) from (select c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on 
alias1.c1 = t3.c3 join cte on alias1.c1 = cte.c11;;"""
+    qt_sql3_3 """explain shape plan with cte as (select c11, c1 from t1 join 
t2 on c1 = c2) select count(*) from (select /*+ leading(t2 t1) */ c1, c11 from 
t1 join t2 on c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3 join cte on 
alias1.c1 = cte.c11;;"""
+    qt_sql3_4 """explain shape plan with cte as (select /*+ leading(t2 t1) */ 
c11, c1 from t1 join t2 on c1 = c2) select /*+ leading(t3 alias1 cte) */ 
count(*) from (select /*+ leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) 
as alias1 join t3 on alias1.c1 = t3.c3 join cte on alias1.c1 = cte.c11;;"""
 
-    // qt_sql3_res_1 """with cte as (select c11, c1 from t1 join t2 on c1 = 
c2) select count(*) from (select c1, c11 from t1 join t2 on c1 = c2) as alias1 
join t3 on alias1.c1 = t3.c3 join cte on alias1.c1 = cte.c11;;"""
-    // qt_sql3_res_2 """with cte as (select /*+ leading(t2 t1) */ c11, c1 from 
t1 join t2 on c1 = c2) select /*+ leading(t3 alias1 cte) */ count(*) from 
(select c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on alias1.c1 = 
t3.c3 join cte on alias1.c1 = cte.c11;;"""
-    // qt_sql3_res_3 """with cte as (select c11, c1 from t1 join t2 on c1 = 
c2) select count(*) from (select /*+ leading(t2 t1) */ c1, c11 from t1 join t2 
on c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3 join cte on alias1.c1 = 
cte.c11;;"""
-    // qt_sql3_res_4 """with cte as (select /*+ leading(t2 t1) */ c11, c1 from 
t1 join t2 on c1 = c2) select /*+ leading(t3 alias1 cte) */ count(*) from 
(select /*+ leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) as alias1 
join t3 on alias1.c1 = t3.c3 join cte on alias1.c1 = cte.c11;;"""
+    qt_sql3_res_1 """with cte as (select c11, c1 from t1 join t2 on c1 = c2) 
select count(*) from (select c1, c11 from t1 join t2 on c1 = c2) as alias1 join 
t3 on alias1.c1 = t3.c3 join cte on alias1.c1 = cte.c11;;"""
+    qt_sql3_res_2 """with cte as (select /*+ leading(t2 t1) */ c11, c1 from t1 
join t2 on c1 = c2) select /*+ leading(t3 alias1 cte) */ count(*) from (select 
c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3 join 
cte on alias1.c1 = cte.c11;;"""
+    qt_sql3_res_3 """with cte as (select c11, c1 from t1 join t2 on c1 = c2) 
select count(*) from (select /*+ leading(t2 t1) */ c1, c11 from t1 join t2 on 
c1 = c2) as alias1 join t3 on alias1.c1 = t3.c3 join cte on alias1.c1 = 
cte.c11;;"""
+    qt_sql3_res_4 """with cte as (select /*+ leading(t2 t1) */ c11, c1 from t1 
join t2 on c1 = c2) select /*+ leading(t3 alias1 cte) */ count(*) from (select 
/*+ leading(t2 t1) */ c1, c11 from t1 join t2 on c1 = c2) as alias1 join t3 on 
alias1.c1 = t3.c3 join cte on alias1.c1 = cte.c11;;"""
 
     // // test multi level subqueries
-    // qt_sql4_1 """explain shape plan select /*+ leading(t3 alias1) */ 
count(*) from (select c1, c11 from t1 join (select c2, c22 from t2 join t4 on 
c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql4_2 """explain shape plan select count(*) from (select /*+ 
leading(alias2 t1) */ c1, c11 from t1 join (select c2, c22 from t2 join t4 on 
c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql4_3 """explain shape plan select count(*) from (select c1, c11 
from t1 join (select /*+ leading(t4 t2) */ c2, c22 from t2 join t4 on c2 = c4) 
as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql4_4 """explain shape plan select /*+ leading(t3 alias1) */ 
count(*) from (select /*+ leading(alias2 t1) */ c1, c11 from t1 join (select 
c2, c22 from t2 join t4 on c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join 
t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_1 """explain shape plan select /*+ leading(t3 alias1) */ count(*) 
from (select c1, c11 from t1 join (select c2, c22 from t2 join t4 on c2 = c4) 
as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_2 """explain shape plan select count(*) from (select /*+ 
leading(alias2 t1) */ c1, c11 from t1 join (select c2, c22 from t2 join t4 on 
c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_3 """explain shape plan select count(*) from (select c1, c11 from 
t1 join (select /*+ leading(t4 t2) */ c2, c22 from t2 join t4 on c2 = c4) as 
alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_4 """explain shape plan select /*+ leading(t3 alias1) */ count(*) 
from (select /*+ leading(alias2 t1) */ c1, c11 from t1 join (select c2, c22 
from t2 join t4 on c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on 
alias1.c1 = t3.c3;"""
     // explain {
     //     sql """shape plan select /*+ leading(t3 alias1) */ count(*) from 
(select c1, c11 from t1 join (select /*+ leading(t4 t2) */ c2, c22 from t2 join 
t4 on c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = 
t3.c3;"""
     //     contains("SyntaxError: leading(t4 t2) Msg:one query block can only 
have one leading clause")
@@ -129,15 +129,15 @@ suite("multi_leading") {
     //     contains("UnUsed: leading(alias2 t1)")
     // }
 
-    // qt_sql4_res_0 """select count(*) from (select c1, c11 from t1 join 
(select c2, c22 from t2 join t4 on c2 = c4) as alias2 on c1 = alias2.c2) as 
alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql4_res_1 """select /*+ leading(t3 alias1) */ count(*) from (select 
c1, c11 from t1 join (select c2, c22 from t2 join t4 on c2 = c4) as alias2 on 
c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql4_res_2 """select count(*) from (select /*+ leading(alias2 t1) */ 
c1, c11 from t1 join (select c2, c22 from t2 join t4 on c2 = c4) as alias2 on 
c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql4_res_3 """select count(*) from (select c1, c11 from t1 join 
(select /*+ leading(t4 t2) */ c2, c22 from t2 join t4 on c2 = c4) as alias2 on 
c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql4_res_4 """select /*+ leading(t3 alias1) */ count(*) from (select 
/*+ leading(alias2 t1) */ c1, c11 from t1 join (select c2, c22 from t2 join t4 
on c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = 
t3.c3;"""
-    // qt_sql4_res_5 """select /*+ leading(t3 alias1) */ count(*) from (select 
c1, c11 from t1 join (select /*+ leading(t4 t2) */ c2, c22 from t2 join t4 on 
c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql4_res_6 """select count(*) from (select /*+ leading(alias2 t1) */ 
c1, c11 from t1 join (select /*+ leading(t4 t2) */ c2, c22 from t2 join t4 on 
c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
-    // qt_sql4_res_7 """select /*+ leading(t3 alias1) */ count(*) from (select 
/*+ leading(alias2 t1) */ c1, c11 from t1 join (select /*+ leading(t4 t2) */ 
c2, c22 from t2 join t4 on c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join 
t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_res_0 """select count(*) from (select c1, c11 from t1 join (select 
c2, c22 from t2 join t4 on c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join 
t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_res_1 """select /*+ leading(t3 alias1) */ count(*) from (select 
c1, c11 from t1 join (select c2, c22 from t2 join t4 on c2 = c4) as alias2 on 
c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_res_2 """select count(*) from (select /*+ leading(alias2 t1) */ 
c1, c11 from t1 join (select c2, c22 from t2 join t4 on c2 = c4) as alias2 on 
c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_res_3 """select count(*) from (select c1, c11 from t1 join (select 
/*+ leading(t4 t2) */ c2, c22 from t2 join t4 on c2 = c4) as alias2 on c1 = 
alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_res_4 """select /*+ leading(t3 alias1) */ count(*) from (select 
/*+ leading(alias2 t1) */ c1, c11 from t1 join (select c2, c22 from t2 join t4 
on c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = 
t3.c3;"""
+    qt_sql4_res_5 """select /*+ leading(t3 alias1) */ count(*) from (select 
c1, c11 from t1 join (select /*+ leading(t4 t2) */ c2, c22 from t2 join t4 on 
c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_res_6 """select count(*) from (select /*+ leading(alias2 t1) */ 
c1, c11 from t1 join (select /*+ leading(t4 t2) */ c2, c22 from t2 join t4 on 
c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join t3 on alias1.c1 = t3.c3;"""
+    qt_sql4_res_7 """select /*+ leading(t3 alias1) */ count(*) from (select 
/*+ leading(alias2 t1) */ c1, c11 from t1 join (select /*+ leading(t4 t2) */ 
c2, c22 from t2 join t4 on c2 = c4) as alias2 on c1 = alias2.c2) as alias1 join 
t3 on alias1.c1 = t3.c3;"""
 
     // // use cte in scalar query
-    // qt_sql5_2 """explain shape plan with  cte as (select c11, c1 from t1)  
SELECT c1 FROM cte group by c1 having sum(cte.c11) > (select /*+ leading(cte 
t1) */ 0.05 * avg(t1.c11) from t1 join cte on t1.c1 = cte.c11 )"""
+    qt_sql5_2 """explain shape plan with  cte as (select c11, c1 from t1)  
SELECT c1 FROM cte group by c1 having sum(cte.c11) > (select /*+ leading(cte 
t1) */ 0.05 * avg(t1.c11) from t1 join cte on t1.c1 = cte.c11 )"""
 }
diff --git a/regression-test/suites/nereids_p0/hint/test_hint.groovy 
b/regression-test/suites/nereids_p0/hint/test_hint.groovy
index 81033e014f1..d279b7c1a1d 100644
--- a/regression-test/suites/nereids_p0/hint/test_hint.groovy
+++ b/regression-test/suites/nereids_p0/hint/test_hint.groovy
@@ -42,20 +42,20 @@ suite("test_hint") {
     sql """create table t2 (c2 int, c22 int) distributed by hash(c2) buckets 3 
properties('replication_num' = '1');"""
 
 // test hint positions, remove join in order to make sure shape stable when no 
use hint
-    // qt_select1_1 """explain shape plan select /*+ leading(t2 broadcast t1) 
*/ count(*) from t1 join t2 on c1 = c2;"""
+    qt_select1_1 """explain shape plan select /*+ leading(t2 broadcast t1) */ 
count(*) from t1 join t2 on c1 = c2;"""
 
-    // qt_select1_2 """explain shape plan /*+ leading(t2 broadcast t1) */ 
select count(*) from t1;"""
+    qt_select1_2 """explain shape plan /*+ leading(t2 broadcast t1) */ select 
count(*) from t1;"""
 
-    // qt_select1_3 """explain shape plan select /*+DBP: 
ROUTE={GROUP_ID(zjaq)}*/ count(*) from t1;"""
+    qt_select1_3 """explain shape plan select /*+DBP: ROUTE={GROUP_ID(zjaq)}*/ 
count(*) from t1;"""
 
-    // qt_select1_4 """explain shape plan/*+DBP: ROUTE={GROUP_ID(zjaq)}*/ 
select count(*) from t1;"""
+    qt_select1_4 """explain shape plan/*+DBP: ROUTE={GROUP_ID(zjaq)}*/ select 
count(*) from t1;"""
 
-    // qt_select1_5 """explain shape plan /*+ leading(t2 broadcast t1) */ 
select /*+ leading(t2 broadcast t1) */ count(*) from t1 join t2 on c1 = c2;"""
+    qt_select1_5 """explain shape plan /*+ leading(t2 broadcast t1) */ select 
/*+ leading(t2 broadcast t1) */ count(*) from t1 join t2 on c1 = c2;"""
 
-    // qt_select1_6 """explain shape plan/*+DBP: ROUTE={GROUP_ID(zjaq)}*/ 
select /*+ leading(t2 broadcast t1) */ count(*) from t1 join t2 on c1 = c2;"""
+    qt_select1_6 """explain shape plan/*+DBP: ROUTE={GROUP_ID(zjaq)}*/ select 
/*+ leading(t2 broadcast t1) */ count(*) from t1 join t2 on c1 = c2;"""
 
-    // qt_select1_7 """explain shape plan /*+ leading(t2 broadcast t1) */ 
select /*+DBP: ROUTE={GROUP_ID(zjaq)}*/ count(*) from t1;"""
+    qt_select1_7 """explain shape plan /*+ leading(t2 broadcast t1) */ select 
/*+DBP: ROUTE={GROUP_ID(zjaq)}*/ count(*) from t1;"""
 
-    // qt_select1_8 """explain shape plan /*+DBP: ROUTE={GROUP_ID(zjaq)}*/ 
select /*+DBP: ROUTE={GROUP_ID(zjaq)}*/ count(*) from t1;"""
+    qt_select1_8 """explain shape plan /*+DBP: ROUTE={GROUP_ID(zjaq)}*/ select 
/*+DBP: ROUTE={GROUP_ID(zjaq)}*/ count(*) from t1;"""
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to