From e8e2c7c945596bf6c2e8f245d2ef20bebe27114d Mon Sep 17 00:00:00 2001 From: feiniaofeiafei Date: Mon, 22 Dec 2025 11:23:24 +0800 Subject: [PATCH] [fix](test) fix case salt_join make it disable join reorder (#59035) fix case salt_join make it disable join reorder. --- .../nereids_rules_p0/salt_join/salt_join.out | 300 +++++++++--------- .../salt_join/salt_join.groovy | 84 ++--- 2 files changed, 195 insertions(+), 189 deletions(-) diff --git a/regression-test/data/nereids_rules_p0/salt_join/salt_join.out b/regression-test/data/nereids_rules_p0/salt_join/salt_join.out index 7a8aa656ca6638..e215f700af5834 100644 --- a/regression-test/data/nereids_rules_p0/salt_join/salt_join.out +++ b/regression-test/data/nereids_rules_p0/salt_join/salt_join.out @@ -88,46 +88,6 @@ 2 def 2 2 def 2 3 abc 4 3 abc 4 --- !leading -- -\N def 2 1 def 2 -\N def 2 2 def 2 -\N def 2 2 def 2 -1 abc 9 1 abc 9 -1 def 2 1 def 2 -1 def 2 2 def 2 -1 def 2 2 def 2 -2 abc 2 1 def 2 -2 abc 2 2 def 2 -2 abc 2 2 def 2 -2 def 2 1 def 2 -2 def 2 2 def 2 -2 def 2 2 def 2 -3 abc 4 3 abc 4 - --- !has_other_equal_condition -- -1 abc 9 1 abc 9 -1 def 2 1 def 2 -2 abc 2 2 def 2 -2 abc 2 2 def 2 -2 def 2 2 def 2 -2 def 2 2 def 2 -3 abc 4 3 abc 4 - --- !has_other_unequal_condition -- -1 def 2 2 def 2 -1 def 2 2 def 2 - --- !test_varchar_skew_value -- -1 abc 1 1 abc 9 -1 abc 9 1 abc 9 -1 def 2 1 def 2 -2 def 2 2 def 2 -2 def 2 2 def 2 -3 abc \N 3 abc \N -3 abc \N 3 abc 4 -3 abc 4 3 abc \N -3 abc 4 3 abc 4 - -- !test_multi_join -- \N def 2 1 def 2 1 def 2 \N def 2 1 def 2 2 def 2 @@ -258,76 +218,6 @@ 2 def 2 2 def 2 2 def 2 3 abc 4 3 abc 4 3 abc 4 --- !leading_multi_join -- -1 abc 1 1 abc 9 1 abc 9 -1 abc 1 1 abc 9 3 abc \N -1 abc 1 1 abc 9 3 abc 4 -1 abc 9 1 abc 9 1 abc 9 -1 abc 9 1 abc 9 3 abc \N -1 abc 9 1 abc 9 3 abc 4 -1 def 2 1 def 2 1 def 2 -1 def 2 1 def 2 2 def 2 -1 def 2 1 def 2 2 def 2 -1 def 2 1 def 2 5 def \N -1 def 2 1 def 2 5 def 8 -2 def 2 2 def 2 1 def 2 -2 def 2 2 def 2 1 def 2 -2 def 2 2 def 2 2 def 2 -2 def 2 2 def 2 2 def 2 -2 def 2 2 def 2 2 def 2 -2 def 2 2 def 2 2 def 2 -2 def 2 2 def 2 5 def \N -2 def 2 2 def 2 5 def \N -2 def 2 2 def 2 5 def 8 -2 def 2 2 def 2 5 def 8 -3 abc \N 3 abc \N 1 abc 9 -3 abc \N 3 abc \N 3 abc \N -3 abc \N 3 abc \N 3 abc 4 -3 abc \N 3 abc 4 1 abc 9 -3 abc \N 3 abc 4 3 abc \N -3 abc \N 3 abc 4 3 abc 4 -3 abc 4 3 abc \N 1 abc 9 -3 abc 4 3 abc \N 3 abc \N -3 abc 4 3 abc \N 3 abc 4 -3 abc 4 3 abc 4 1 abc 9 -3 abc 4 3 abc 4 3 abc \N -3 abc 4 3 abc 4 3 abc 4 - --- !leading_multi_join_bracket -- -1 abc 1 1 abc 9 1 abc 9 -1 abc 1 1 abc 9 3 abc \N -1 abc 1 1 abc 9 3 abc 4 -1 abc 9 1 abc 9 1 abc 9 -1 abc 9 1 abc 9 3 abc \N -1 abc 9 1 abc 9 3 abc 4 -1 def 2 1 def 2 1 def 2 -1 def 2 1 def 2 2 def 2 -1 def 2 1 def 2 2 def 2 -1 def 2 1 def 2 5 def \N -1 def 2 1 def 2 5 def 8 -2 def 2 2 def 2 1 def 2 -2 def 2 2 def 2 1 def 2 -2 def 2 2 def 2 2 def 2 -2 def 2 2 def 2 2 def 2 -2 def 2 2 def 2 2 def 2 -2 def 2 2 def 2 2 def 2 -2 def 2 2 def 2 5 def \N -2 def 2 2 def 2 5 def \N -2 def 2 2 def 2 5 def 8 -2 def 2 2 def 2 5 def 8 -3 abc \N 3 abc \N 1 abc 9 -3 abc \N 3 abc \N 3 abc \N -3 abc \N 3 abc \N 3 abc 4 -3 abc \N 3 abc 4 1 abc 9 -3 abc \N 3 abc 4 3 abc \N -3 abc \N 3 abc 4 3 abc 4 -3 abc 4 3 abc \N 1 abc 9 -3 abc 4 3 abc \N 3 abc \N -3 abc 4 3 abc \N 3 abc 4 -3 abc 4 3 abc 4 1 abc 9 -3 abc 4 3 abc 4 3 abc \N -3 abc 4 3 abc 4 3 abc 4 - -- !agg -- \N 3 1 4 @@ -405,46 +295,6 @@ 2 def 2 2 def 2 3 abc 4 3 abc 4 --- !shape_leading_inner_subquery -- -PhysicalResultSink ---hashAgg[GLOBAL] -----hashAgg[LOCAL] -------hashJoin[INNER_JOIN] hashCondition=((alias1.c1 = t3.c3)) otherCondition=() ---------hashJoin[INNER_JOIN] hashCondition=((alias1.c1 = alias2.c2) and (r1$c$1 = r2$c$2)) otherCondition=() -----------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t4.c4)) otherCondition=() -------------PhysicalOlapScan[t2] -------------PhysicalOlapScan[t4] -----------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((skewValue$c$5 = alias1.c1)) otherCondition=() -------------PhysicalGenerate ---------------PhysicalUnion -------------PhysicalOlapScan[t1] ---------PhysicalOlapScan[t3] - -Hint log: -Used: leading(alias2 shuffle_skew t1 ) -UnUsed: -SyntaxError: - --- !shape_leading_inner_subquery_switch -- -PhysicalResultSink ---hashAgg[GLOBAL] -----hashAgg[LOCAL] -------hashJoin[INNER_JOIN] hashCondition=((alias1.c1 = t3.c3)) otherCondition=() ---------hashJoin[INNER_JOIN] hashCondition=((alias1.c1 = alias2.c2) and (r1$c$1 = r2$c$2)) otherCondition=() -----------PhysicalOlapScan[t1] -----------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((skewValue$c$5 = alias2.c2)) otherCondition=() -------------PhysicalGenerate ---------------PhysicalUnion -------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t4.c4)) otherCondition=() ---------------PhysicalOlapScan[t2] ---------------PhysicalOlapScan[t4] ---------PhysicalOlapScan[t3] - -Hint log: -Used: leading(t1 shuffle_skew alias2 ) -UnUsed: -SyntaxError: - -- !inner_skew_value -- 1 \N 1 \N @@ -970,3 +820,153 @@ Used: [shuffle_skew]_1 UnUsed: SyntaxError: +-- !leading_multi_join -- +1 abc 1 1 abc 9 1 abc 9 +1 abc 1 1 abc 9 3 abc \N +1 abc 1 1 abc 9 3 abc 4 +1 abc 9 1 abc 9 1 abc 9 +1 abc 9 1 abc 9 3 abc \N +1 abc 9 1 abc 9 3 abc 4 +1 def 2 1 def 2 1 def 2 +1 def 2 1 def 2 2 def 2 +1 def 2 1 def 2 2 def 2 +1 def 2 1 def 2 5 def \N +1 def 2 1 def 2 5 def 8 +2 def 2 2 def 2 1 def 2 +2 def 2 2 def 2 1 def 2 +2 def 2 2 def 2 2 def 2 +2 def 2 2 def 2 2 def 2 +2 def 2 2 def 2 2 def 2 +2 def 2 2 def 2 2 def 2 +2 def 2 2 def 2 5 def \N +2 def 2 2 def 2 5 def \N +2 def 2 2 def 2 5 def 8 +2 def 2 2 def 2 5 def 8 +3 abc \N 3 abc \N 1 abc 9 +3 abc \N 3 abc \N 3 abc \N +3 abc \N 3 abc \N 3 abc 4 +3 abc \N 3 abc 4 1 abc 9 +3 abc \N 3 abc 4 3 abc \N +3 abc \N 3 abc 4 3 abc 4 +3 abc 4 3 abc \N 1 abc 9 +3 abc 4 3 abc \N 3 abc \N +3 abc 4 3 abc \N 3 abc 4 +3 abc 4 3 abc 4 1 abc 9 +3 abc 4 3 abc 4 3 abc \N +3 abc 4 3 abc 4 3 abc 4 + +-- !leading_multi_join_bracket -- +1 abc 1 1 abc 9 1 abc 9 +1 abc 1 1 abc 9 3 abc \N +1 abc 1 1 abc 9 3 abc 4 +1 abc 9 1 abc 9 1 abc 9 +1 abc 9 1 abc 9 3 abc \N +1 abc 9 1 abc 9 3 abc 4 +1 def 2 1 def 2 1 def 2 +1 def 2 1 def 2 2 def 2 +1 def 2 1 def 2 2 def 2 +1 def 2 1 def 2 5 def \N +1 def 2 1 def 2 5 def 8 +2 def 2 2 def 2 1 def 2 +2 def 2 2 def 2 1 def 2 +2 def 2 2 def 2 2 def 2 +2 def 2 2 def 2 2 def 2 +2 def 2 2 def 2 2 def 2 +2 def 2 2 def 2 2 def 2 +2 def 2 2 def 2 5 def \N +2 def 2 2 def 2 5 def \N +2 def 2 2 def 2 5 def 8 +2 def 2 2 def 2 5 def 8 +3 abc \N 3 abc \N 1 abc 9 +3 abc \N 3 abc \N 3 abc \N +3 abc \N 3 abc \N 3 abc 4 +3 abc \N 3 abc 4 1 abc 9 +3 abc \N 3 abc 4 3 abc \N +3 abc \N 3 abc 4 3 abc 4 +3 abc 4 3 abc \N 1 abc 9 +3 abc 4 3 abc \N 3 abc \N +3 abc 4 3 abc \N 3 abc 4 +3 abc 4 3 abc 4 1 abc 9 +3 abc 4 3 abc 4 3 abc \N +3 abc 4 3 abc 4 3 abc 4 + +-- !leading -- +\N def 2 1 def 2 +\N def 2 2 def 2 +\N def 2 2 def 2 +1 abc 9 1 abc 9 +1 def 2 1 def 2 +1 def 2 2 def 2 +1 def 2 2 def 2 +2 abc 2 1 def 2 +2 abc 2 2 def 2 +2 abc 2 2 def 2 +2 def 2 1 def 2 +2 def 2 2 def 2 +2 def 2 2 def 2 +3 abc 4 3 abc 4 + +-- !has_other_equal_condition -- +1 abc 9 1 abc 9 +1 def 2 1 def 2 +2 abc 2 2 def 2 +2 abc 2 2 def 2 +2 def 2 2 def 2 +2 def 2 2 def 2 +3 abc 4 3 abc 4 + +-- !has_other_unequal_condition -- +1 def 2 2 def 2 +1 def 2 2 def 2 + +-- !test_varchar_skew_value -- +1 abc 1 1 abc 9 +1 abc 9 1 abc 9 +1 def 2 1 def 2 +2 def 2 2 def 2 +2 def 2 2 def 2 +3 abc \N 3 abc \N +3 abc \N 3 abc 4 +3 abc 4 3 abc \N +3 abc 4 3 abc 4 + +-- !shape_leading_inner_subquery -- +PhysicalResultSink +--hashAgg[GLOBAL] +----hashAgg[LOCAL] +------hashJoin[INNER_JOIN] hashCondition=((alias1.c1 = t3.c3)) otherCondition=() +--------hashJoin[INNER_JOIN] hashCondition=((alias1.c1 = alias2.c2) and (r1$c$1 = r2$c$2)) otherCondition=() +----------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t4.c4)) otherCondition=() +------------PhysicalOlapScan[t2] +------------PhysicalOlapScan[t4] +----------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((skewValue$c$5 = alias1.c1)) otherCondition=() +------------PhysicalGenerate +--------------PhysicalUnion +------------PhysicalOlapScan[t1] +--------PhysicalOlapScan[t3] + +Hint log: +Used: leading(alias2 shuffle_skew t1 ) +UnUsed: +SyntaxError: + +-- !shape_leading_inner_subquery_switch -- +PhysicalResultSink +--hashAgg[GLOBAL] +----hashAgg[LOCAL] +------hashJoin[INNER_JOIN] hashCondition=((alias1.c1 = t3.c3)) otherCondition=() +--------hashJoin[INNER_JOIN] hashCondition=((alias1.c1 = alias2.c2) and (r1$c$1 = r2$c$2)) otherCondition=() +----------PhysicalOlapScan[t1] +----------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((skewValue$c$5 = alias2.c2)) otherCondition=() +------------PhysicalGenerate +--------------PhysicalUnion +------------hashJoin[INNER_JOIN] hashCondition=((t2.c2 = t4.c4)) otherCondition=() +--------------PhysicalOlapScan[t2] +--------------PhysicalOlapScan[t4] +--------PhysicalOlapScan[t3] + +Hint log: +Used: leading(t1 shuffle_skew alias2 ) +UnUsed: +SyntaxError: + diff --git a/regression-test/suites/nereids_rules_p0/salt_join/salt_join.groovy b/regression-test/suites/nereids_rules_p0/salt_join/salt_join.groovy index bea4814efb34eb..fbf17db586e205 100644 --- a/regression-test/suites/nereids_rules_p0/salt_join/salt_join.groovy +++ b/regression-test/suites/nereids_rules_p0/salt_join/salt_join.groovy @@ -20,6 +20,7 @@ suite("salt_join") { sql "SET ignore_shape_nodes='PhysicalDistribute,PhysicalProject'" sql "set disable_nereids_rules='prune_empty_partition'" sql "set runtime_filter_mode=OFF" + sql "set disable_join_reorder=true" sql "drop table if exists test_skew9;" sql """create table test_skew9(a int,c varchar(100), b int) distributed by hash(a) buckets 32 properties("replication_num"="1");""" sql """insert into test_skew9 values(1,'abc',9),(1,'abc',1),(1,'def',2),(null,'def',2),(2,'abc',2),(3,'abc',4),(5,'abc',6),(2,'def',2),(5,'abc',null),(3,'abc',null)""" @@ -41,18 +42,6 @@ suite("salt_join") { qt_skew_value_only_null """ select * from test_skew9 tl inner join [shuffle[skew(tl.b(null))]] test_skew10 tr on tl.b = tr.b order by 1,2,3,4,5,6; """ - qt_leading """ - select /*+leading(tl shuffle [skew(tl.b(1,2))] tr) */ * from test_skew9 tl join test_skew10 tr on tl.b=tr.b order by 1,2,3,4,5,6; - """ - qt_has_other_equal_condition """ - select /*+leading(tl shuffle [skew(tl.b(1,2))] tr) */ * from test_skew9 tl join test_skew10 tr on tl.b=tr.b and tl.a=tr.a order by 1,2,3,4,5,6; - """ - qt_has_other_unequal_condition """ - select /*+leading(tl shuffle [skew(tl.b(1,2))] tr) */ * from test_skew9 tl join test_skew10 tr on tl.b=tr.b and tl.at2.b;" qt_null_safe_equal_left_other_and_null_shape "explain shape plan select t1.a,t1.b,t2.a,t2.b from test_null_safe3 t1 left join[shuffle[skew(t1.b(1,2,null))]] test_null_safe4 t2 on t1.b<=>t2.b;" qt_null_safe_equal_right_other_and_null_shape "explain shape plan select t1.a,t1.b,t2.a,t2.b from test_null_safe3 t1 right join[shuffle[skew(t2.b(1,2,null))]] test_null_safe4 t2 on t1.b<=>t2.b;" + + sql "set disable_join_reorder=false" + + qt_leading_multi_join """ + select /*+leading(tl shuffle [skew(tl.c("abc","def"))] tr shuffle[skew(tl.c("abc","def"))] tt) */ * from + test_skew9 tl join test_skew10 tr on tl.c=tr.c and tl.a=tr.a inner join test_skew10 tt on tl.c = tt.c + order by 1,2,3,4,5,6,7,8,9; + """ + qt_leading_multi_join_bracket """ + select /*+leading(tl shuffle [skew(tl.c("abc","def"))] {tr shuffle[skew(tr.c("abc","def"))] tt}) */ * from + test_skew9 tl join test_skew10 tr on tl.c=tr.c and tl.a=tr.a inner join test_skew10 tt on tr.c = tt.c + order by 1,2,3,4,5,6,7,8,9; + """ + + qt_leading """ + select /*+leading(tl shuffle [skew(tl.b(1,2))] tr) */ * from test_skew9 tl join test_skew10 tr on tl.b=tr.b order by 1,2,3,4,5,6; + """ + qt_has_other_equal_condition """ + select /*+leading(tl shuffle [skew(tl.b(1,2))] tr) */ * from test_skew9 tl join test_skew10 tr on tl.b=tr.b and tl.a=tr.a order by 1,2,3,4,5,6; + """ + qt_has_other_unequal_condition """ + select /*+leading(tl shuffle [skew(tl.b(1,2))] tr) */ * from test_skew9 tl join test_skew10 tr on tl.b=tr.b and tl.a