diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/TryEliminateUninterestedPredicates.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/TryEliminateUninterestedPredicates.java index 79bd0a54bf5830..3faf56f0f3829e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/TryEliminateUninterestedPredicates.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/TryEliminateUninterestedPredicates.java @@ -109,7 +109,9 @@ public Expression visit(Expression originExpr, Context parentContext) { 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; } diff --git a/regression-test/suites/nereids_rules_p0/partition_prune/test_partition_unique_model.groovy b/regression-test/suites/nereids_rules_p0/partition_prune/test_partition_unique_model.groovy new file mode 100644 index 00000000000000..cfd4f28e6053e9 --- /dev/null +++ b/regression-test/suites/nereids_rules_p0/partition_prune/test_partition_unique_model.groovy @@ -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)" + } + +}