From 07fa5041ee12bb1259d551e13e7af4be2d30a888 Mon Sep 17 00:00:00 2001 From: LiBinfeng <1204975323@qq.com> Date: Tue, 25 Jun 2024 09:33:13 +0800 Subject: [PATCH] [Fix](Nereids) fix leading with different be instance number --- .../data/nereids_p0/hint/fix_leading.out | 77 +++++++------------ .../suites/nereids_p0/hint/fix_leading.groovy | 7 +- 2 files changed, 31 insertions(+), 53 deletions(-) diff --git a/regression-test/data/nereids_p0/hint/fix_leading.out b/regression-test/data/nereids_p0/hint/fix_leading.out index 9b75ff8d907092..32cd182094434f 100644 --- a/regression-test/data/nereids_p0/hint/fix_leading.out +++ b/regression-test/data/nereids_p0/hint/fix_leading.out @@ -1,23 +1,18 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !select1 -- PhysicalResultSink ---PhysicalDistribute -----PhysicalProject -------hashJoin[INNER_JOIN](t1.c1 = t3.c3)(t1.c1 = t4.c4) ---------NestedLoopJoin[CROSS_JOIN] -----------PhysicalOlapScan[t1] -----------PhysicalDistribute -------------filter((t2.c2 = t2.c2)) ---------------PhysicalOlapScan[t2] ---------PhysicalDistribute -----------NestedLoopJoin[CROSS_JOIN](t4.c4 = t3.c3)(t3.c3 = t4.c4) -------------PhysicalOlapScan[t3] -------------PhysicalDistribute ---------------PhysicalOlapScan[t4] +--hashJoin[INNER_JOIN](t1.c1 = t3.c3)(t1.c1 = t4.c4) +----NestedLoopJoin[CROSS_JOIN] +------PhysicalOlapScan[t1] +------filter((t2.c2 = t2.c2)) +--------PhysicalOlapScan[t2] +----NestedLoopJoin[CROSS_JOIN](t4.c4 = t3.c3)(t3.c3 = t4.c4) +------PhysicalOlapScan[t3] +------PhysicalOlapScan[t4] Hint log: Used: leading({ t1 t2 } { t3 t4 } ) -UnUsed: +UnUsed: SyntaxError: -- !select2_1_1 -- @@ -231,50 +226,36 @@ SyntaxError: PhysicalResultSink --hashAgg[GLOBAL] ----hashAgg[LOCAL] -------PhysicalProject ---------NestedLoopJoin[RIGHT_OUTER_JOIN](t3.c3 > 500) -----------PhysicalDistribute[DistributionSpecGather] -------------PhysicalProject ---------------NestedLoopJoin[LEFT_OUTER_JOIN](t1.c1 < 200)(t1.c1 > 500) -----------------PhysicalProject -------------------PhysicalOlapScan[t1] -----------------PhysicalDistribute[DistributionSpecReplicated] -------------------PhysicalProject ---------------------filter((t2.c2 > 500)) -----------------------PhysicalOlapScan[t2] -----------PhysicalDistribute[DistributionSpecGather] -------------PhysicalProject ---------------PhysicalOlapScan[t3] +------NestedLoopJoin[RIGHT_OUTER_JOIN](t3.c3 > 500) +--------NestedLoopJoin[LEFT_OUTER_JOIN](t1.c1 < 200)(t1.c1 > 500) +----------PhysicalOlapScan[t1] +----------filter((t2.c2 > 500)) +------------PhysicalOlapScan[t2] +--------PhysicalOlapScan[t3] Hint log: Used: leading(t1 t2 t3 ) -UnUsed: +UnUsed: SyntaxError: -- !select6_1 -- PhysicalResultSink --hashAgg[GLOBAL] -----PhysicalDistribute[DistributionSpecGather] -------hashAgg[LOCAL] ---------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] +----hashAgg[LOCAL] +------hashJoin[INNER_JOIN](t1.c1 = t6.c6) +--------hashJoin[INNER_JOIN](t1.c1 = t2.c2)(t1.c1 = t3.c3)(t1.c1 = t4.c4)(t1.c1 = t5.c5) +----------PhysicalOlapScan[t1] +----------NestedLoopJoin[CROSS_JOIN](t3.c3 = t5.c5)(t2.c2 = t4.c4)(t2.c2 = t5.c5)(t5.c5 = t2.c2)(t4.c4 = t2.c2)(t5.c5 = t3.c3)(t4.c4 = t3.c3)(t3.c3 = t4.c4) +------------NestedLoopJoin[CROSS_JOIN](t3.c3 = t2.c2)(t2.c2 = t3.c3) +--------------PhysicalOlapScan[t2] +--------------PhysicalOlapScan[t3] +------------NestedLoopJoin[CROSS_JOIN](t5.c5 = t4.c4)(t4.c4 = t5.c5) +--------------PhysicalOlapScan[t4] +--------------PhysicalOlapScan[t5] +--------PhysicalOlapScan[t6] Hint log: Used: leading(t1 { { t2 t3 } { t4 t5 } } t6 ) -UnUsed: +UnUsed: SyntaxError: diff --git a/regression-test/suites/nereids_p0/hint/fix_leading.groovy b/regression-test/suites/nereids_p0/hint/fix_leading.groovy index b2e57a40dbecfd..9e120af123143b 100644 --- a/regression-test/suites/nereids_p0/hint/fix_leading.groovy +++ b/regression-test/suites/nereids_p0/hint/fix_leading.groovy @@ -30,7 +30,7 @@ suite("fix_leading") { 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'" + sql "set ignore_shape_nodes='PhysicalProject, PhysicalDistribute'" // create tables @@ -197,15 +197,12 @@ suite("fix_leading") { // check whether we have all tables 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") + 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;""" - // check filter in duplicated aliasName explain { sql """shape plan SELECT