This is an automated email from the ASF dual-hosted git repository.
englefly pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 6a614c3e7bc [regression](nereids) add regression case for
transposeSemiJoinAgg/transposeSemiJoinAggProject rules (#27664)
6a614c3e7bc is described below
commit 6a614c3e7bca499b9eda3711a86ab54e5230e17d
Author: minghong <[email protected]>
AuthorDate: Fri Dec 1 08:19:16 2023 +0800
[regression](nereids) add regression case for
transposeSemiJoinAgg/transposeSemiJoinAggProject rules (#27664)
add case for transposeSemiJoinAgg/transposeSemiJoinAggProject rules
---
.../rules/rewrite/TransposeSemiJoinAggProject.java | 2 -
.../transposeJoin/transposeSemiJoinAgg.out | 130 ++++++++++++++++++++
.../transposeJoin/transposeSemiJoinAgg.groovy | 135 +++++++++++++++++++++
3 files changed, 265 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAggProject.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAggProject.java
index 24ca535eed8..9c6b355e465 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAggProject.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAggProject.java
@@ -19,7 +19,6 @@ package org.apache.doris.nereids.rules.rewrite;
import org.apache.doris.nereids.rules.Rule;
import org.apache.doris.nereids.rules.RuleType;
-import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
@@ -35,7 +34,6 @@ public class TransposeSemiJoinAggProject extends
OneRewriteRuleFactory {
.whenNot(join ->
ConnectContext.get().getSessionVariable().isDisableJoinReorder())
.when(join -> join.getJoinType().isLeftSemiOrAntiJoin())
.when(join -> join.left().isAllSlots())
- .when(join -> join.left().getProjects().stream().allMatch(n ->
n instanceof Slot))
.then(join -> {
LogicalProject<LogicalAggregate<Plan>> project =
join.left();
LogicalAggregate<Plan> aggregate = project.child();
diff --git
a/regression-test/data/nereids_rules_p0/transposeJoin/transposeSemiJoinAgg.out
b/regression-test/data/nereids_rules_p0/transposeJoin/transposeSemiJoinAgg.out
new file mode 100644
index 00000000000..49cf927de50
--- /dev/null
+++
b/regression-test/data/nereids_rules_p0/transposeJoin/transposeSemiJoinAgg.out
@@ -0,0 +1,130 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !groupby_positive_case --
+PhysicalResultSink
+--PhysicalDistribute
+----PhysicalProject
+------hashAgg[LOCAL]
+--------hashJoin[LEFT_SEMI_JOIN] hashCondition=((T3.a = T2.a))
otherCondition=() build RFs:RF0 a->[a]
+----------PhysicalProject
+------------filter((T1.__DORIS_DELETE_SIGN__ = 0))
+--------------PhysicalOlapScan[T1] apply RFs: RF0
+----------PhysicalDistribute
+------------PhysicalProject
+--------------filter((T2.__DORIS_DELETE_SIGN__ = 0))
+----------------PhysicalOlapScan[T2]
+
+-- !groupby_negative_case --
+PhysicalResultSink
+--PhysicalDistribute
+----PhysicalProject
+------hashJoin[LEFT_SEMI_JOIN] hashCondition=((T3.D = expr_cast(a as BIGINT)))
otherCondition=()
+--------PhysicalDistribute
+----------PhysicalProject
+------------hashAgg[LOCAL]
+--------------PhysicalProject
+----------------filter((T1.__DORIS_DELETE_SIGN__ = 0))
+------------------PhysicalOlapScan[T1]
+--------PhysicalDistribute
+----------PhysicalProject
+------------filter((T2.__DORIS_DELETE_SIGN__ = 0))
+--------------PhysicalOlapScan[T2]
+
+-- !grouping_positive_case --
+PhysicalResultSink
+--PhysicalDistribute
+----PhysicalProject
+------hashAgg[LOCAL]
+--------hashJoin[LEFT_SEMI_JOIN] hashCondition=((T3.a = T2.a))
otherCondition=() build RFs:RF0 a->[a]
+----------PhysicalDistribute
+------------PhysicalRepeat
+--------------PhysicalProject
+----------------filter((T1.__DORIS_DELETE_SIGN__ = 0))
+------------------PhysicalOlapScan[T1] apply RFs: RF0
+----------PhysicalDistribute
+------------PhysicalProject
+--------------filter((T2.__DORIS_DELETE_SIGN__ = 0))
+----------------PhysicalOlapScan[T2]
+
+-- !grouping_negative_case --
+PhysicalResultSink
+--PhysicalDistribute
+----PhysicalProject
+------hashJoin[LEFT_SEMI_JOIN] hashCondition=((T3.D = expr_cast(a as BIGINT)))
otherCondition=()
+--------PhysicalDistribute
+----------PhysicalProject
+------------hashAgg[GLOBAL]
+--------------PhysicalDistribute
+----------------hashAgg[LOCAL]
+------------------PhysicalRepeat
+--------------------PhysicalProject
+----------------------filter((T1.__DORIS_DELETE_SIGN__ = 0))
+------------------------PhysicalOlapScan[T1]
+--------PhysicalDistribute
+----------PhysicalProject
+------------filter((T2.__DORIS_DELETE_SIGN__ = 0))
+--------------PhysicalOlapScan[T2]
+
+-- !groupby_positive_case2 --
+PhysicalResultSink
+--PhysicalDistribute
+----hashAgg[LOCAL]
+------hashJoin[LEFT_SEMI_JOIN] hashCondition=((T3.a = T2.a)) otherCondition=()
build RFs:RF0 a->[a]
+--------PhysicalProject
+----------filter((T1.__DORIS_DELETE_SIGN__ = 0))
+------------PhysicalOlapScan[T1] apply RFs: RF0
+--------PhysicalDistribute
+----------PhysicalProject
+------------filter((T2.__DORIS_DELETE_SIGN__ = 0))
+--------------PhysicalOlapScan[T2]
+
+-- !groupby_negative_case2 --
+PhysicalResultSink
+--PhysicalDistribute
+----PhysicalProject
+------hashJoin[LEFT_SEMI_JOIN] hashCondition=((T3.D = expr_cast(a as BIGINT)))
otherCondition=()
+--------PhysicalDistribute
+----------PhysicalProject
+------------hashAgg[LOCAL]
+--------------PhysicalProject
+----------------filter((T1.__DORIS_DELETE_SIGN__ = 0))
+------------------PhysicalOlapScan[T1]
+--------PhysicalDistribute
+----------PhysicalProject
+------------filter((T2.__DORIS_DELETE_SIGN__ = 0))
+--------------PhysicalOlapScan[T2]
+
+-- !grouping_positive_case2 --
+PhysicalResultSink
+--PhysicalDistribute
+----PhysicalProject
+------hashAgg[LOCAL]
+--------hashJoin[LEFT_SEMI_JOIN] hashCondition=((T3.a = T2.a))
otherCondition=() build RFs:RF0 a->[a]
+----------PhysicalDistribute
+------------PhysicalRepeat
+--------------PhysicalProject
+----------------filter((T1.__DORIS_DELETE_SIGN__ = 0))
+------------------PhysicalOlapScan[T1] apply RFs: RF0
+----------PhysicalDistribute
+------------PhysicalProject
+--------------filter((T2.__DORIS_DELETE_SIGN__ = 0))
+----------------PhysicalOlapScan[T2]
+
+-- !grouping_negative_case2 --
+PhysicalResultSink
+--PhysicalDistribute
+----PhysicalProject
+------hashJoin[LEFT_SEMI_JOIN] hashCondition=((T3.D = expr_cast(a as BIGINT)))
otherCondition=()
+--------PhysicalDistribute
+----------PhysicalProject
+------------hashAgg[GLOBAL]
+--------------PhysicalDistribute
+----------------hashAgg[LOCAL]
+------------------PhysicalRepeat
+--------------------PhysicalProject
+----------------------filter((T1.__DORIS_DELETE_SIGN__ = 0))
+------------------------PhysicalOlapScan[T1]
+--------PhysicalDistribute
+----------PhysicalProject
+------------filter((T2.__DORIS_DELETE_SIGN__ = 0))
+--------------PhysicalOlapScan[T2]
+
diff --git
a/regression-test/suites/nereids_rules_p0/transposeJoin/transposeSemiJoinAgg.groovy
b/regression-test/suites/nereids_rules_p0/transposeJoin/transposeSemiJoinAgg.groovy
new file mode 100644
index 00000000000..ea557f0de78
--- /dev/null
+++
b/regression-test/suites/nereids_rules_p0/transposeJoin/transposeSemiJoinAgg.groovy
@@ -0,0 +1,135 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("transposeSemiJoinAgg") {
+ // filter about invisible column "DORIS_DELETE_SIGN = 0" has no impaction
on partition pruning
+ String db = context.config.getDbNameByFile(context.file)
+ sql "use ${db}"
+ sql "SET enable_nereids_planner=true"
+ sql "SET enable_fallback_to_original_planner=false"
+ sql "set partition_pruning_expand_threshold=10;"
+ sql "drop table if exists T1;"
+ sql """
+ CREATE TABLE T1 (
+ a INT NULL,
+ b INT NULL,
+ c INT NULL
+ ) ENGINE=OLAP
+ UNIQUE KEY(`a`)
+ COMMENT 'OLAP'
+ DISTRIBUTED BY HASH(`a`) BUCKETS 10
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "min_load_replica_num" = "-1",
+ "is_being_synced" = "false",
+ "storage_format" = "V2",
+ "light_schema_change" = "true",
+ "disable_auto_compaction" = "false",
+ "enable_single_replica_compaction" = "false",
+ "group_commit_interval_ms" = "10000"
+ ); """
+
+ sql "drop table if exists T2;"
+ sql """
+ CREATE TABLE T2 (
+ a INT NULL,
+ b INT NULL,
+ c INT NULL
+ ) ENGINE=OLAP
+ UNIQUE KEY(`a`)
+ COMMENT 'OLAP'
+ DISTRIBUTED BY HASH(`a`) BUCKETS 10
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "min_load_replica_num" = "-1",
+ "is_being_synced" = "false",
+ "storage_format" = "V2",
+ "light_schema_change" = "true",
+ "disable_auto_compaction" = "false",
+ "enable_single_replica_compaction" = "false",
+ "group_commit_interval_ms" = "10000"
+ );
+ """
+ // RULE: TransposeSemiJoinAggProject
+ // 1. group-by(without grouping sets)
+ // agg-leftSemi => leftSemi-agg
+ qt_groupby_positive_case """
+ explain shape plan
+ select T3.A
+ from (select A, B, sum(C) from T1 group by A, B) T3
+ left semi join T2 on T3.A=T2.A;
+ """
+
+ // agg-leftSemi: agg not pushed down
+ qt_groupby_negative_case """
+ explain shape plan
+ select T3.A
+ from (select A, B, sum(C) as D from T1 group by A, B) T3
+ left semi join T2 on T3.D=T2.A;
+ """
+
+ // 2 grouping sets
+ // agg-leftSemi => leftSemi-agg
+ qt_grouping_positive_case """
+ explain shape plan
+ select T3.A
+ from (select A, B, sum(C) from T1 group by grouping sets ((A, B),
(A))) T3
+ left semi join T2 on T3.A=T2.A;
+ """
+
+ // agg-leftSemi: agg not pushed down
+ qt_grouping_negative_case """
+ explain shape plan
+ select T3.A
+ from (select A, B, sum(C) as D from T1 group by grouping sets ((A, B),
(A), ())) T3
+ left semi join T2 on T3.D=T2.A;
+ """
+
+ // RULE: TransposeSemiJoinAgg
+ // 1. group-by(without grouping sets)
+ // agg-leftSemi => leftSemi-agg
+ qt_groupby_positive_case2 """
+ explain shape plan
+ select T3.A
+ from (select A from T1 group by A) T3
+ left semi join T2 on T3.A=T2.A;
+ """
+
+ // agg-leftSemi: agg not pushed down
+ qt_groupby_negative_case2 """
+ explain shape plan
+ select T3.D
+ from (select sum(C) as D from T1 group by A) T3
+ left semi join T2 on T3.D=T2.A;
+ """
+
+ // 2 grouping sets
+ // agg-leftSemi => leftSemi-agg
+ qt_grouping_positive_case2 """
+ explain shape plan
+ select T3.A
+ from (select A from T1 group by grouping sets ((A, B), (A))) T3
+ left semi join T2 on T3.A=T2.A;
+ """
+ // agg-leftSemi: agg not pushed down
+ qt_grouping_negative_case2 """
+ explain shape plan
+ select T3.D
+ 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;
+ """
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]