[Fix](Nereids) fix hint cases with random result (#31865)

This commit is contained in:
LiBinfeng
2024-03-07 13:57:21 +08:00
committed by yiguolei
parent 29b858d8c9
commit fa411f88df
4 changed files with 16 additions and 148 deletions

View File

@ -442,7 +442,7 @@ PhysicalResultSink
----------------------PhysicalOlapScan[t2]
Hint log:
Used:
Used: leading(t3 { t1 t2 } )
UnUsed: [shuffle]_2
SyntaxError:

View File

@ -1815,157 +1815,25 @@
119
-- !select70_1 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------PhysicalProject
----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
------------PhysicalProject
--------------PhysicalOlapScan[t1]
------------PhysicalDistribute[DistributionSpecHash]
--------------PhysicalProject
----------------PhysicalOlapScan[t2]
Hint log:
Used:
UnUsed:
SyntaxError: leading(t1 t3) Msg:can not find table: t3
1719
-- !select70_2 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------PhysicalProject
----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
------------PhysicalProject
--------------PhysicalOlapScan[t1]
------------PhysicalDistribute[DistributionSpecHash]
--------------PhysicalProject
----------------PhysicalOlapScan[t2]
Hint log:
Used:
UnUsed:
SyntaxError: leading(t1 t5) Msg:can not find table: t5
1719
-- !select71_1 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------PhysicalProject
----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
------------PhysicalProject
--------------PhysicalOlapScan[t1]
------------PhysicalDistribute[DistributionSpecHash]
--------------PhysicalProject
----------------PhysicalOlapScan[t2]
Hint log:
Used:
UnUsed:
SyntaxError: leading(t1 t1 t2) Msg:duplicated table
1719
-- !select71_2 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------PhysicalProject
----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
------------PhysicalProject
--------------PhysicalOlapScan[t1]
------------PhysicalDistribute[DistributionSpecHash]
--------------PhysicalProject
----------------PhysicalOlapScan[t2]
Hint log:
Used:
UnUsed:
SyntaxError: leading(t1 t2 t2) Msg:duplicated table
1719
-- !select72_1 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------PhysicalProject
----------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
------------PhysicalProject
--------------PhysicalOlapScan[t1]
------------PhysicalDistribute[DistributionSpecHash]
--------------hashJoin[LEFT_SEMI_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
----------------PhysicalProject
------------------PhysicalOlapScan[t2]
----------------PhysicalDistribute[DistributionSpecHash]
------------------PhysicalProject
--------------------hashJoin[INNER_JOIN] hashCondition=((t3.c3 = t4.c4)) otherCondition=()
----------------------PhysicalProject
------------------------PhysicalOlapScan[t4]
----------------------PhysicalDistribute[DistributionSpecHash]
------------------------PhysicalProject
--------------------------PhysicalOlapScan[t3]
Hint log:
Used: leading(t4 t3 )
UnUsed:
SyntaxError:
1235
-- !select72_2 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------PhysicalProject
----------hashJoin[LEFT_SEMI_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
--------------PhysicalProject
----------------PhysicalOlapScan[t1]
--------------PhysicalDistribute[DistributionSpecHash]
----------------PhysicalProject
------------------PhysicalOlapScan[t2]
------------PhysicalDistribute[DistributionSpecHash]
--------------PhysicalProject
----------------hashJoin[INNER_JOIN] hashCondition=((t3.c3 = t4.c4)) otherCondition=()
------------------PhysicalProject
--------------------PhysicalOlapScan[t3]
------------------PhysicalDistribute[DistributionSpecHash]
--------------------PhysicalProject
----------------------PhysicalOlapScan[t4]
Hint log:
Used: leading(t1 t2 )
UnUsed:
SyntaxError:
1235
-- !select73_1 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------PhysicalProject
----------hashJoin[LEFT_SEMI_JOIN] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
------------hashJoin[INNER_JOIN] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
--------------PhysicalProject
----------------PhysicalOlapScan[t1]
--------------PhysicalDistribute[DistributionSpecHash]
----------------PhysicalProject
------------------PhysicalOlapScan[t2]
------------PhysicalDistribute[DistributionSpecHash]
--------------PhysicalProject
----------------hashJoin[INNER_JOIN] hashCondition=((t3.c3 = t4.c4)) otherCondition=()
------------------PhysicalProject
--------------------PhysicalOlapScan[t4]
------------------PhysicalDistribute[DistributionSpecHash]
--------------------PhysicalProject
----------------------PhysicalOlapScan[t3]
Hint log:
Used: leading(t1 t2 ) leading(t4 t3 )
UnUsed:
SyntaxError:
1235
-- !select81_1 --
259

View File

@ -104,7 +104,7 @@ suite("test_distribute") {
qt_select5_1 """explain shape plan select count(*) from t1 join [shuffle] t2 on c1 > c2;"""
qt_select5_2 """explain shape plan select count(*) from t1 join [broadcast] t2 on c1 > c2;"""
qt_select6_1 """explain shape plan select count(*) from t1 join [shuffle] t2 on c1 > c2 join t3 on c2 > c3 where c1 < 100;"""
qt_select6_1 """explain shape plan select /*+ leading(t3 {t1 t2}) */ count(*) from t1 join [shuffle] t2 on c1 > c2 join t3 on c2 > c3 where c1 < 100;"""
qt_select6_2 """explain shape plan select count(*) from t1 join t2 on c1 > c2 join t3 on c2 > c3 where c1 < 100;"""
// (A leftjoin B on (Pab)) leftjoin C on (Pac) = (A leftjoin C on (Pac)) leftjoin B on (Pab)

View File

@ -794,19 +794,19 @@ suite("test_leading") {
qt_select68_13 """select /*+ leading(t3 {t2 t1}) */ count(*) from t1 left semi join t2 on c1 = c2 left anti join t3 on c1 = c3 where exists (select 1 from t3 join t4 on c3 = c4);"""
// wrong table name
qt_select70_1 """explain shape plan select /*+ leading(t1 t3) */ count(*) from t1 join t2 on c1 = c2;"""
qt_select70_2 """explain shape plan select /*+ leading(t1 t5) */ count(*) from t1 join t2 on c1 = c2;"""
qt_select70_1 """select /*+ leading(t1 t3) */ count(*) from t1 join t2 on c1 = c2;"""
qt_select70_2 """select /*+ leading(t1 t5) */ count(*) from t1 join t2 on c1 = c2;"""
// duplicate table name
qt_select71_1 """explain shape plan select /*+ leading(t1 t1 t2) */ count(*) from t1 join t2 on c1 = c2;"""
qt_select71_2 """explain shape plan select /*+ leading(t1 t2 t2) */ count(*) from t1 join t2 on c1 = c2;"""
qt_select71_1 """select /*+ leading(t1 t1 t2) */ count(*) from t1 join t2 on c1 = c2;"""
qt_select71_2 """select /*+ leading(t1 t2 t2) */ count(*) from t1 join t2 on c1 = c2;"""
// different scope
qt_select72_1 """explain shape plan select count(*) from t1 join t2 on c1 = c2 where c2 in (select /*+ leading(t4 t3) */ c3 from t3 join t4 on c3 = c4);"""
qt_select72_2 """explain shape plan select /*+ leading(t1 t2) */ count(*) from t1 join t2 on c1 = c2 where c2 in (select c3 from t3 join t4 on c3 = c4);"""
qt_select72_1 """select count(*) from t1 join t2 on c1 = c2 where c2 in (select /*+ leading(t4 t3) */ c3 from t3 join t4 on c3 = c4);"""
qt_select72_2 """select /*+ leading(t1 t2) */ count(*) from t1 join t2 on c1 = c2 where c2 in (select c3 from t3 join t4 on c3 = c4);"""
// multi leading hint
qt_select73_1 """explain shape plan select /*+ leading(t1 t2) */ count(*) from t1 join t2 on c1 = c2 where c2 in (select /*+ leading(t4 t3) */ c3 from t3 join t4 on c3 = c4);"""
qt_select73_1 """select /*+ leading(t1 t2) */ count(*) from t1 join t2 on c1 = c2 where c2 in (select /*+ leading(t4 t3) */ c3 from t3 join t4 on c3 = c4);"""
// alias
// inner join + anti join