Skip to content

Commit

Permalink
[fix](nereids) patition prune is affected by non-paritition-key condi…
Browse files Browse the repository at this point in the history
…tion (apache#26873)

 stop propagate Context.childrenContainsNonInterestedSlots if expr changed to TRUE
  • Loading branch information
englefly authored and 胥剑旭 committed Dec 14, 2023
1 parent 7bc56fa commit f33ed13
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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)"
}

}

0 comments on commit f33ed13

Please sign in to comment.