[fix](nereids) patition prune is affected by non-paritition-key condition (#26873)

stop propagate Context.childrenContainsNonInterestedSlots if expr changed to TRUE
This commit is contained in:
minghong
2023-11-15 14:46:59 +08:00
committed by GitHub
parent 5dbc3cbba4
commit a1d139080d
2 changed files with 61 additions and 1 deletions

View File

@ -109,7 +109,9 @@ public class TryEliminateUninterestedPredicates extends DefaultExpressionRewrite
public Expression visitAnd(And and, Context parentContext) {
Expression left = and.left();
Context leftContext = new Context();
Expression newLeft = this.visit(left, leftContext);
// Expression newLeft = this.visit(left, leftContext);
Expression newLeft = left.accept(this, leftContext);
if (leftContext.childrenContainsNonInterestedSlots) {
newLeft = BooleanLiteral.TRUE;
}

View File

@ -0,0 +1,58 @@
// 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_partition_unique_model") {
// 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 xinan;"
sql """
create table xinan
(
init_date int null
)
engine=olap
unique key(init_date)
partition by range(init_date)
(partition p202209 values[("20220901"), ("20221001")),
partition p202210 values[("20221001"), ("20221101")))
distributed by hash (init_date) buckets auto
properties(
"replication_allocation" = "tag.location.default: 1"
);
"""
sql "insert into xinan values(20220901), (20221003);"
explain {
sql "select * from xinan where init_date >=20221001;"
contains "partitions=1/2 (p202210)"
}
explain {
sql "select * from xinan where init_date<20221101;"
contains "partitions=2/2 (p202209,p202210)"
}
explain {
sql "select * from xinan where init_date >=20221001 and init_date<20221101;"
contains "partitions=1/2 (p202210)"
}
}