[fix](nereids) do not transpose semi join agg when mark join (#32475)
This commit is contained in:
@ -36,6 +36,7 @@ public class TransposeSemiJoinAgg extends OneRewriteRuleFactory {
|
||||
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)) {
|
||||
|
||||
@ -33,6 +33,7 @@ public class TransposeSemiJoinAggProject extends OneRewriteRuleFactory {
|
||||
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();
|
||||
|
||||
@ -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]
|
||||
|
||||
|
||||
@ -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
|
||||
@ -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;
|
||||
"""
|
||||
}
|
||||
Reference in New Issue
Block a user