Skip to content

Commit

Permalink
[fix](cases) fix unstable leading cases (apache#46441)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

test_leading case unstable because do not explicit assign all distribute
type for all joins, solved by add all distribute type for all joins
  • Loading branch information
LiBinfeng-01 authored Jan 7, 2025
1 parent 131742d commit 04ef8d8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 98 deletions.
118 changes: 36 additions & 82 deletions regression-test/data/nereids_p0/hint/test_leading.out
Original file line number Diff line number Diff line change
Expand Up @@ -2147,52 +2147,6 @@
-- !select88_13 --
119

-- !select90_1 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
----------PhysicalOlapScan[t1]
----------PhysicalOlapScan[t2]

Hint log:
Used: [broadcast]_2
UnUsed:
SyntaxError:

-- !select90_3 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
----------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
------------PhysicalOlapScan[t1]
------------PhysicalOlapScan[t2]
----------PhysicalOlapScan[t3]

Hint log:
Used: [broadcast]_2 [shuffle]_3
UnUsed:
SyntaxError:

-- !select90_5 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------hashJoin[RIGHT_OUTER_JOIN shuffle] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
----------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
------------PhysicalOlapScan[t1]
------------PhysicalOlapScan[t2]
----------PhysicalOlapScan[t3]

Hint log:
Used: [broadcast]_2 [shuffle]_3
UnUsed:
SyntaxError:

-- !select92_1 --
PhysicalResultSink
--hashAgg[GLOBAL]
Expand Down Expand Up @@ -2301,8 +2255,8 @@ PhysicalResultSink
----------PhysicalOlapScan[t3]

Hint log:
Used: leading(t1 t2 broadcast t3 )
UnUsed:
Used: leading(t1 broadcast t2 broadcast t3 )
UnUsed:
SyntaxError:

-- !select93_2 --
Expand All @@ -2317,8 +2271,8 @@ PhysicalResultSink
------------PhysicalOlapScan[t3]

Hint log:
Used: leading(t1 { t2 broadcast t3 } )
UnUsed:
Used: leading(t1 broadcast { t2 broadcast t3 } )
UnUsed:
SyntaxError:

-- !select93_3 --
Expand All @@ -2333,8 +2287,8 @@ PhysicalResultSink
------------PhysicalOlapScan[t2]

Hint log:
Used: leading(t1 { t3 broadcast t2 } )
UnUsed:
Used: leading(t1 broadcast { t3 broadcast t2 } )
UnUsed:
SyntaxError:

-- !select93_4 --
Expand All @@ -2349,8 +2303,8 @@ PhysicalResultSink
----------PhysicalOlapScan[t3]

Hint log:
Used: leading(t2 t1 broadcast t3 )
UnUsed:
Used: leading(t2 broadcast t1 broadcast t3 )
UnUsed:
SyntaxError:

-- !select93_5 --
Expand All @@ -2365,8 +2319,8 @@ PhysicalResultSink
------------PhysicalOlapScan[t3]

Hint log:
Used: leading(t2 { t1 broadcast t3 } )
UnUsed:
Used: leading(t2 broadcast { t1 broadcast t3 } )
UnUsed:
SyntaxError:

-- !select93_6 --
Expand All @@ -2381,24 +2335,24 @@ PhysicalResultSink
------------PhysicalOlapScan[t1]

Hint log:
Used: leading(t2 { t3 broadcast t1 } )
UnUsed:
Used: leading(t2 broadcast { t3 broadcast t1 } )
UnUsed:
SyntaxError:

-- !select94_2 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------hashJoin[INNER_JOIN broadcast] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
--------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
------------PhysicalOlapScan[t1]
------------PhysicalOlapScan[t2]
----------PhysicalOlapScan[t3]

Hint log:
Used: leading(t1 shuffle t2 t3 )
UnUsed:
Used: leading(t1 shuffle t2 shuffle t3 )
UnUsed:
SyntaxError:

-- !select94_2 --
Expand All @@ -2408,13 +2362,13 @@ PhysicalResultSink
------hashAgg[LOCAL]
--------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
----------PhysicalOlapScan[t1]
----------hashJoin[INNER_JOIN broadcast] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
------------PhysicalOlapScan[t2]
------------PhysicalOlapScan[t3]

Hint log:
Used: leading(t1 shuffle { t2 t3 } )
UnUsed:
Used: leading(t1 shuffle { t2 shuffle t3 } )
UnUsed:
SyntaxError:

-- !select94_2 --
Expand All @@ -2424,29 +2378,29 @@ PhysicalResultSink
------hashAgg[LOCAL]
--------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
----------PhysicalOlapScan[t1]
----------hashJoin[INNER_JOIN broadcast] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
------------PhysicalOlapScan[t3]
------------PhysicalOlapScan[t2]

Hint log:
Used: leading(t1 shuffle { t3 t2 } )
UnUsed:
Used: leading(t1 shuffle { t3 shuffle t2 } )
UnUsed:
SyntaxError:

-- !select94_2 --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------hashJoin[INNER_JOIN broadcast] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
--------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t2.c2 = t3.c3)) otherCondition=()
----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t1.c1 = t2.c2)) otherCondition=()
------------PhysicalOlapScan[t2]
------------PhysicalOlapScan[t1]
----------PhysicalOlapScan[t3]

Hint log:
Used: leading(t2 shuffle t1 t3 )
UnUsed:
Used: leading(t2 shuffle t1 shuffle t3 )
UnUsed:
SyntaxError:

-- !select94_2 --
Expand All @@ -2456,13 +2410,13 @@ PhysicalResultSink
------hashAgg[LOCAL]
--------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t1.c1 = t2.c2) and (t2.c2 = t3.c3)) otherCondition=()
----------PhysicalOlapScan[t2]
----------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = t3.c3)) otherCondition=()
----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t1.c1 = t3.c3)) otherCondition=()
------------PhysicalOlapScan[t1]
------------PhysicalOlapScan[t3]

Hint log:
Used: leading(t2 shuffle { t1 t3 } )
UnUsed:
Used: leading(t2 shuffle { t1 shuffle t3 } )
UnUsed:
SyntaxError:

-- !select94_2 --
Expand All @@ -2472,13 +2426,13 @@ PhysicalResultSink
------hashAgg[LOCAL]
--------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t1.c1 = t2.c2) and (t2.c2 = t3.c3)) otherCondition=()
----------PhysicalOlapScan[t2]
----------hashJoin[INNER_JOIN broadcast] hashCondition=((t1.c1 = t3.c3)) otherCondition=()
----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t1.c1 = t3.c3)) otherCondition=()
------------PhysicalOlapScan[t3]
------------PhysicalOlapScan[t1]

Hint log:
Used: leading(t2 shuffle { t3 t1 } )
UnUsed:
Used: leading(t2 shuffle { t3 shuffle t1 } )
UnUsed:
SyntaxError:

-- !select95_1 --
Expand Down Expand Up @@ -2509,8 +2463,8 @@ PhysicalResultSink
----------PhysicalOlapScan[t3]

Hint log:
Used: leading(t2 broadcast t1 t3 )
UnUsed:
Used: leading(t2 broadcast t1 broadcast t3 )
UnUsed:
SyntaxError:

-- !select95_8 --
Expand All @@ -2525,8 +2479,8 @@ PhysicalResultSink
------------PhysicalOlapScan[t2]

Hint log:
Used: leading(t3 broadcast { t1 t2 } )
UnUsed:
Used: leading(t3 broadcast { t1 broadcast t2 } )
UnUsed:
SyntaxError:

-- !select95_9 --
Expand All @@ -2541,8 +2495,8 @@ PhysicalResultSink
------------PhysicalOlapScan[t1]

Hint log:
Used: leading(t3 broadcast { t2 t1 } )
UnUsed:
Used: leading(t3 broadcast { t2 broadcast t1 } )
UnUsed:
SyntaxError:

-- !select96_1 --
Expand Down
32 changes: 16 additions & 16 deletions regression-test/suites/nereids_p0/hint/test_leading.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -982,19 +982,19 @@ suite("test_leading") {
qt_select92_5 """explain shape plan select /*+ leading(t2 shuffle {t1 broadcast t3}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select92_6 """explain shape plan select /*+ leading(t2 shuffle {t3 broadcast t1}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""

qt_select93_1 """explain shape plan select /*+ leading(t1 t2 broadcast t3) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_2 """explain shape plan select /*+ leading(t1 {t2 broadcast t3}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_3 """explain shape plan select /*+ leading(t1 {t3 broadcast t2}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_4 """explain shape plan select /*+ leading(t2 t1 broadcast t3) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_5 """explain shape plan select /*+ leading(t2 {t1 broadcast t3}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_6 """explain shape plan select /*+ leading(t2 {t3 broadcast t1}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""

qt_select94_2 """explain shape plan select /*+ leading(t1 shuffle t2 t3) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t1 shuffle {t2 t3}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t1 shuffle {t3 t2}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t2 shuffle t1 t3) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t2 shuffle {t1 t3}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t2 shuffle {t3 t1}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_1 """explain shape plan select /*+ leading(t1 broadcast t2 broadcast t3) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_2 """explain shape plan select /*+ leading(t1 broadcast {t2 broadcast t3}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_3 """explain shape plan select /*+ leading(t1 broadcast {t3 broadcast t2}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_4 """explain shape plan select /*+ leading(t2 broadcast t1 broadcast t3) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_5 """explain shape plan select /*+ leading(t2 broadcast {t1 broadcast t3}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select93_6 """explain shape plan select /*+ leading(t2 broadcast {t3 broadcast t1}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""

qt_select94_2 """explain shape plan select /*+ leading(t1 shuffle t2 shuffle t3) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t1 shuffle {t2 shuffle t3}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t1 shuffle {t3 shuffle t2}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t2 shuffle t1 shuffle t3) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t2 shuffle {t1 shuffle t3}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select94_2 """explain shape plan select /*+ leading(t2 shuffle {t3 shuffle t1}) */ count(*) from t1 join t2 on c1 = c2 join t3 on c2 = c3;"""

// outer join
qt_select95_1 """explain shape plan select /*+ leading(t1 broadcast t2 broadcast t3) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
Expand All @@ -1006,7 +1006,7 @@ suite("test_leading") {
sql """shape plan select /*+ leading(t1 broadcast {t3 t2}) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
contains("UnUsed: leading(t1 broadcast { t3 t2 })")
}
qt_select95_4 """explain shape plan select /*+ leading(t2 broadcast t1 t3) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select95_4 """explain shape plan select /*+ leading(t2 broadcast t1 broadcast t3) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
explain {
sql """shape plan select /*+ leading(t2 broadcast {t1 t3}) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
contains("UnUsed: leading(t2 broadcast { t1 t3 })")
Expand All @@ -1019,8 +1019,8 @@ suite("test_leading") {
sql """shape plan select /*+ leading(t3 broadcast t1 t2) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
contains("UnUsed: leading(t3 broadcast t1 t2)")
}
qt_select95_8 """explain shape plan select /*+ leading(t3 broadcast {t1 t2}) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select95_9 """explain shape plan select /*+ leading(t3 broadcast {t2 t1}) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select95_8 """explain shape plan select /*+ leading(t3 broadcast {t1 broadcast t2}) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
qt_select95_9 """explain shape plan select /*+ leading(t3 broadcast {t2 broadcast t1}) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""

qt_select96_1 """explain shape plan select /*+ leading(t1 shuffle t2 broadcast t3) */ count(*) from t1 left outer join t2 on c1 = c2 join t3 on c2 = c3;"""
explain {
Expand Down

0 comments on commit 04ef8d8

Please sign in to comment.