Skip to content

Commit

Permalink
[fix](nereids) do not transpose semi join agg when mark join (#32475)
Browse files Browse the repository at this point in the history
  • Loading branch information
iwanttobepowerful authored and Doris-Extras committed Apr 13, 2024
1 parent 30b9997 commit 5e43fd6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public Rule build() {
return logicalJoin(logicalAggregate(), any())
.whenNot(join -> ConnectContext.get().getSessionVariable().isDisableJoinReorder())
.when(join -> join.getJoinType().isLeftSemiOrAntiJoin())
.whenNot(join -> join.isMarkJoin())
.then(join -> {
LogicalAggregate<Plan> aggregate = join.left();
if (!canTranspose(aggregate, join)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public Rule build() {
return logicalJoin(logicalProject(logicalAggregate()), any())
.whenNot(join -> ConnectContext.get().getSessionVariable().isDisableJoinReorder())
.when(join -> join.getJoinType().isLeftSemiOrAntiJoin())
.whenNot(join -> join.isMarkJoin())
.when(join -> join.left().isAllSlots())
.then(join -> {
LogicalProject<LogicalAggregate<Plan>> project = join.left();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,11 @@ PhysicalResultSink
----filter((T2.__DORIS_DELETE_SIGN__ = 0))
------PhysicalOlapScan[T2]

-- !groupby_negative_case3 --
PhysicalResultSink
--hashJoin[LEFT_SEMI_JOIN] hashCondition=() otherCondition=() markCondition=((T3.len = T3.len))
----hashAgg[GLOBAL]
------hashAgg[LOCAL]
--------PhysicalOlapScan[T3]
----PhysicalOlapScan[T3]

Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ suite("transposeSemiJoinAgg") {
sql '''
alter table T2 modify column a set stats ('ndv'='100', 'num_nulls'='0', 'row_count'='100');
'''

sql "drop table if exists T3;"
sql """
CREATE TABLE T3 (
str varchar(100),
len int
) DUPLICATE KEY(str)
DISTRIBUTED BY HASH(str) BUCKETS 10
PROPERTIES("replication_num" = "1");
"""

// RULE: TransposeSemiJoinAggProject
// 1. group-by(without grouping sets)
// agg-leftSemi => leftSemi-agg
Expand Down Expand Up @@ -146,4 +157,9 @@ suite("transposeSemiJoinAgg") {
from (select sum(C) as D from T1 group by grouping sets ((a, b), (a), ())) T3
left semi join T2 on T3.D=T2.a;
"""
// https://github.com/apache/doris/issues/31308
qt_groupby_negative_case3 """
explain shape plan
select case when len in (select len from T3) then 1 else 1 end c1 from T3 group by len;
"""
}

0 comments on commit 5e43fd6

Please sign in to comment.