xzj7019 commented on code in PR #39450: URL: https://github.com/apache/doris/pull/39450#discussion_r1723231282
########## regression-test/suites/nereids_rules_p0/infer_predicate/pull_up_predicate_set_op.groovy: ########## @@ -0,0 +1,215 @@ +// 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("test_pull_up_predicate_set_op") { + sql "set enable_nereids_planner=true" + sql "set enable_fallback_to_original_planner=false" + sql """SET ignore_shape_nodes='PhysicalDistribute,PhysicalProject'""" + sql 'set runtime_filter_mode=off' + sql 'set enable_fold_constant_by_be=true' + sql 'set debug_skip_fold_constant=false' + + sql "drop table if exists test_pull_up_predicate_set_op1" + sql "drop table if exists test_pull_up_predicate_set_op2" + sql "drop table if exists test_pull_up_predicate_set_op3" + + sql """ + CREATE TABLE `test_pull_up_predicate_set_op1` ( + `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 `test_pull_up_predicate_set_op2` ( + `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 `test_pull_up_predicate_set_op3` ( + `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 test_pull_up_predicate_set_op1 values(1,'d2',3,5),(0,'d2',3,5),(-3,'d2',2,2),(-2,'d2',2,2); + """ + + sql """ + insert into test_pull_up_predicate_set_op2 values(1,'d2',2,2),(-3,'d2',2,2),(0,'d2',3,5); + """ + + sql """ + insert into test_pull_up_predicate_set_op3 values(1,'d2',2,2),(-2,'d2',2,2),(0,'d2',3,5); + """ + + qt_intersect """ + explain shape plan + select * from (select a,b from test_pull_up_predicate_set_op1 where a<1 intersect select a,b from test_pull_up_predicate_set_op2 where b>'ab') t inner join test_pull_up_predicate_set_op3 t3 + on t3.a=t.a and t3.b=t.b; + """ + qt_except """ + explain shape plan + select * from (select a,b from test_pull_up_predicate_set_op1 where a<1 except select a,b from test_pull_up_predicate_set_op2 where b>'ab') t inner join test_pull_up_predicate_set_op3 t3 + on t3.a=t.a and t3.b=t.b; + """ + qt_union """ + explain shape plan + select * from (select a,b from test_pull_up_predicate_set_op1 where a<1 union select a,b from test_pull_up_predicate_set_op2 where a<1) t inner join test_pull_up_predicate_set_op3 t3 + on t3.a=t.a and t3.b=t.b; + """ + + qt_intersect_res """ + select t.a,t3.b from (select a,b from test_pull_up_predicate_set_op1 where a<1 intersect select a,b from test_pull_up_predicate_set_op2 where b>'ab') t inner join test_pull_up_predicate_set_op3 t3 + on t3.a=t.a and t3.b=t.b order by 1,2; + """ + qt_except_res """ + select t.a,t3.b from (select a,b from test_pull_up_predicate_set_op1 where a<1 except select a,b from test_pull_up_predicate_set_op2 where b>'ab') t inner join test_pull_up_predicate_set_op3 t3 + on t3.a=t.a and t3.b=t.b order by 1,2; + """ + qt_union_res """ + select t.a,t3.b from (select a,b from test_pull_up_predicate_set_op1 where a<1 union select a,b from test_pull_up_predicate_set_op2 where a<1) t inner join test_pull_up_predicate_set_op3 t3 + on t3.a=t.a and t3.b=t.b order by 1,2; """ + + qt_intersect_one_side """ + explain shape plan + select t.a,t3.b from (select a,b from test_pull_up_predicate_set_op1 intersect select a,b from test_pull_up_predicate_set_op2 where b>'ab') t inner join test_pull_up_predicate_set_op3 t3 + on t3.a=t.a and t3.b=t.b; + """ + + qt_intersect_one_side_no_filter """ + explain shape plan + select t.a,t3.b from (select a,b from test_pull_up_predicate_set_op1 intersect select a,b from test_pull_up_predicate_set_op2 ) t inner join test_pull_up_predicate_set_op3 t3 + on t3.a=t.a and t3.b=t.b; + """ + + qt_except_first_no_filter """ + explain shape plan + select t.a,t3.b from (select a,b from test_pull_up_predicate_set_op1 except select a,b from test_pull_up_predicate_set_op2 where b>'ab') t inner join test_pull_up_predicate_set_op3 t3 + on t3.a=t.a and t3.b=t.b; + """ + qt_except_second_no_filter """ + explain shape plan + select t.a,t3.b from (select a,b from test_pull_up_predicate_set_op1 where a>1 except select a,b from test_pull_up_predicate_set_op2 ) t inner join test_pull_up_predicate_set_op3 t3 Review Comment: add case for pulling the filter or the constant condition up with non-inner join? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org