-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[improvement](nereids) support extract from disjunction in join on co…
- Loading branch information
1 parent
b120e89
commit 8fcce4f
Showing
6 changed files
with
251 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
regression-test/data/nereids_rules_p0/push_down_filter/extract_from_disjunction_in_join.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !left_semi -- | ||
PhysicalResultSink | ||
--hashJoin[LEFT_SEMI_JOIN] hashCondition=((t1.b = t2.b)) otherCondition=((((t2.a = 9) AND (t1.a = 1)) OR ((t1.a = 2) AND (t2.a = 8)))) | ||
----filter(a IN (1, 2)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t1] | ||
----filter(a IN (8, 9)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t2] | ||
|
||
-- !right_semi -- | ||
PhysicalResultSink | ||
--hashJoin[LEFT_SEMI_JOIN] hashCondition=((t1.b = t2.b)) otherCondition=((((t2.a = 9) AND (t1.a = 1)) OR ((t1.a = 2) AND (t2.a = 8)))) | ||
----filter(a IN (8, 9)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t2] | ||
----filter(a IN (1, 2)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t1] | ||
|
||
-- !left -- | ||
PhysicalResultSink | ||
--hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.b = t2.b)) otherCondition=((((t2.a = 9) AND (t1.a = 1)) OR ((t1.a = 2) AND (t2.a = 8))) and a IN (1, 2)) | ||
----PhysicalOlapScan[extract_from_disjunction_in_join_t1] | ||
----filter(a IN (8, 9)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t2] | ||
|
||
-- !right -- | ||
PhysicalResultSink | ||
--hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.b = t2.b)) otherCondition=((((t2.a = 9) AND (t1.a = 1)) OR ((t1.a = 2) AND (t2.a = 8))) and a IN (8, 9)) | ||
----PhysicalOlapScan[extract_from_disjunction_in_join_t2] | ||
----filter(a IN (1, 2)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t1] | ||
|
||
-- !left_anti -- | ||
PhysicalResultSink | ||
--hashJoin[LEFT_ANTI_JOIN] hashCondition=((t1.b = t2.b)) otherCondition=((((t2.a = 9) AND (t1.a = 1)) OR ((t1.a = 2) AND (t2.a = 8))) and a IN (1, 2)) | ||
----PhysicalOlapScan[extract_from_disjunction_in_join_t1] | ||
----filter(a IN (8, 9)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t2] | ||
|
||
-- !right_anti -- | ||
PhysicalResultSink | ||
--hashJoin[LEFT_ANTI_JOIN] hashCondition=((t1.b = t2.b)) otherCondition=((((t2.a = 9) AND (t1.a = 1)) OR ((t1.a = 2) AND (t2.a = 8))) and a IN (8, 9)) | ||
----PhysicalOlapScan[extract_from_disjunction_in_join_t2] | ||
----filter(a IN (1, 2)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t1] | ||
|
||
-- !inner -- | ||
PhysicalResultSink | ||
--hashJoin[INNER_JOIN] hashCondition=((t1.b = t2.b)) otherCondition=((((t2.a = 9) AND (t1.a = 1)) OR ((t1.a = 2) AND (t2.a = 8)))) | ||
----filter(a IN (1, 2)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t1] | ||
----filter(a IN (8, 9)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t2] | ||
|
||
-- !outer -- | ||
PhysicalResultSink | ||
--hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.b = t2.b)) otherCondition=((((t2.a = 9) AND (t1.a = 1)) OR ((t1.a = 2) AND (t2.a = 8))) and a IN (1, 2)) | ||
----filter((t1.c = 3)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t1] | ||
----filter(a IN (8, 9)) | ||
------PhysicalOlapScan[extract_from_disjunction_in_join_t2] | ||
|
||
-- !left_semi_res -- | ||
1 | ||
2 | ||
|
||
-- !right_semi_res -- | ||
8 | ||
9 | ||
|
||
-- !left_res -- | ||
1 | ||
2 | ||
3 | ||
|
||
-- !right_res -- | ||
\N | ||
1 | ||
2 | ||
|
||
-- !left_anti_res -- | ||
3 | ||
|
||
-- !right_anti_res -- | ||
7 | ||
|
||
-- !inner_res -- | ||
1 | ||
2 | ||
|
||
-- !outer_res -- | ||
1 | ||
2 | ||
3 | ||
|
File renamed without changes.
83 changes: 83 additions & 0 deletions
83
...ion-test/suites/nereids_rules_p0/push_down_filter/extract_from_disjunction_in_join.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// 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("extract_from_disjunction_in_join") { | ||
sql "SET enable_nereids_planner=true" | ||
sql "SET enable_fallback_to_original_planner=false" | ||
sql "set ignore_shape_nodes='PhysicalDistribute,PhysicalProject'" | ||
sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" | ||
sql "set runtime_filter_mode=OFF" | ||
|
||
|
||
sql "drop table if exists extract_from_disjunction_in_join_t1" | ||
sql "drop table if exists extract_from_disjunction_in_join_t2" | ||
sql """ | ||
CREATE TABLE `extract_from_disjunction_in_join_t1` ( | ||
`a` INT NULL, | ||
`b` VARCHAR(10) NULL, | ||
`c` INT NULL, | ||
`d` INT NULL | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`a`, `b`) | ||
DISTRIBUTED BY RANDOM BUCKETS AUTO | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1" | ||
); | ||
""" | ||
sql """ | ||
CREATE TABLE `extract_from_disjunction_in_join_t2` ( | ||
`a` INT NULL, | ||
`b` VARCHAR(10) NULL, | ||
`c` INT NULL, | ||
`d` INT NULL | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`a`, `b`) | ||
DISTRIBUTED BY RANDOM BUCKETS AUTO | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1" | ||
);""" | ||
|
||
sql "insert into extract_from_disjunction_in_join_t1 values(1,'d2',3,5),(2,'d2',3,5),(3,'d2',3,5);" | ||
sql "insert into extract_from_disjunction_in_join_t2 values(7,'d2',2,2),(8,'d2',2,2),(9,'d2',2,2);" | ||
qt_left_semi """explain shape plan | ||
select * from extract_from_disjunction_in_join_t1 t1 left semi join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8);""" | ||
qt_right_semi """explain shape plan | ||
select * from extract_from_disjunction_in_join_t1 t1 right semi join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8);""" | ||
qt_left """explain shape plan | ||
select * from extract_from_disjunction_in_join_t1 t1 left join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8);""" | ||
qt_right """explain shape plan | ||
select * from extract_from_disjunction_in_join_t1 t1 right join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8);""" | ||
qt_left_anti """explain shape plan | ||
select * from extract_from_disjunction_in_join_t1 t1 left anti join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8);""" | ||
qt_right_anti """explain shape plan | ||
select * from extract_from_disjunction_in_join_t1 t1 right anti join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8);""" | ||
qt_inner """explain shape plan | ||
select * from extract_from_disjunction_in_join_t1 t1 inner join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8);""" | ||
qt_outer """explain shape plan | ||
select * from extract_from_disjunction_in_join_t1 t1 full join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8) | ||
where t1.c=3;""" | ||
|
||
qt_left_semi_res "select t1.a from extract_from_disjunction_in_join_t1 t1 left semi join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8) order by 1;" | ||
qt_right_semi_res "select t2.a from extract_from_disjunction_in_join_t1 t1 right semi join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8) order by 1;" | ||
qt_left_res "select t1.a from extract_from_disjunction_in_join_t1 t1 left join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8) order by 1;" | ||
qt_right_res "select t1.a from extract_from_disjunction_in_join_t1 t1 right join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8) order by 1;" | ||
qt_left_anti_res "select t1.a from extract_from_disjunction_in_join_t1 t1 left anti join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8) order by 1;" | ||
qt_right_anti_res "select t2.a from extract_from_disjunction_in_join_t1 t1 right anti join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8) order by 1;" | ||
qt_inner_res "select t1.a from extract_from_disjunction_in_join_t1 t1 inner join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8) order by 1;" | ||
qt_outer_res """select t1.a from extract_from_disjunction_in_join_t1 t1 full join extract_from_disjunction_in_join_t2 t2 on t1.b=t2.b and (t2.a=9 && t1.a=1 || t1.a=2 && t2.a=8) | ||
where t1.c=3 order by 1;""" | ||
} |
File renamed without changes.