Skip to content

Commit

Permalink
[fix](nereids) partition prunner evaluates "not x=const" on single no…
Browse files Browse the repository at this point in the history
…de range #29164 (#29359)
  • Loading branch information
englefly authored Jan 2, 2024
1 parent 8505a74 commit 0cc1666
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public EvaluateRangeResult visitOr(Or or, EvaluateRangeInput context) {
@Override
public EvaluateRangeResult visitNot(Not not, EvaluateRangeInput context) {
EvaluateRangeResult result = evaluateChildrenThenThis(not, context);
if (result.isRejectNot()) {
if (result.isRejectNot() && !result.result.equals(BooleanLiteral.TRUE)) {
Map<Slot, ColumnRange> newRanges = Maps.newHashMap();
for (Map.Entry<Slot, ColumnRange> entry : result.childrenResult.get(0).columnRanges.entrySet()) {
Slot slot = entry.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,40 @@ suite("test_multi_range_partition") {
sql "select * from pt where not k3 < 5;"
contains "partitions=3/3 (p1,p2,p3)"
}

sql "drop table if exists tt"
sql """
CREATE TABLE `tt` (
a bigint(20) NULL,
b bigint(20) null
) ENGINE=OLAP
duplicate KEY(`a`)
COMMENT 'OLAP'
PARTITION BY RANGE(`a`, `b`)
(PARTITION p0 VALUES [("-2147483648", "-9223372036854775808"), ("5", "5")),
PARTITION p1 VALUES [("5", "5"), ("7", "7")),
PARTITION p2 VALUES [("7", "7"), ("2147483647", "2147483647000")))
DISTRIBUTED BY HASH(`b`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"is_being_synced" = "false",
"storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false"
);
"""
sql "SET enable_nereids_planner=true"
sql "SET enable_fallback_to_original_planner=false"
sql "insert into tt values (0, 0), (6, 6), (8, 8)"
explain {
sql """SELECT
*
FROM
tt
WHERE
( NOT ( a IN ( 5 ) )
AND b BETWEEN 2 AND 13 )"""
contains "partitions=3/3 (p0,p1,p2)"
}
}

0 comments on commit 0cc1666

Please sign in to comment.