This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 7546783cd75 [BUG] fix scan range boundary handling is incorrect #34832
(#35829)
7546783cd75 is described below
commit 7546783cd756f404be6c041a638fe509f0b81424
Author: zhiqiang <[email protected]>
AuthorDate: Wed Jun 5 10:01:23 2024 +0800
[BUG] fix scan range boundary handling is incorrect #34832 (#35829)
cherry pick from #34832
Co-authored-by: shee <[email protected]>
---
be/src/exec/olap_common.h | 5 ++-
.../data/query_p0/scan_range/test_scan_range.out | 10 +++++
.../query_p0/scan_range/test_scan_range.groovy | 45 ++++++++++++++++++++++
3 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/be/src/exec/olap_common.h b/be/src/exec/olap_common.h
index c7456a7eac6..67183f20036 100644
--- a/be/src/exec/olap_common.h
+++ b/be/src/exec/olap_common.h
@@ -695,14 +695,15 @@ bool
ColumnValueRange<primitive_type>::convert_to_close_range(
bool is_empty = false;
if (!is_begin_include()) {
- if (_low_value == TYPE_MIN) {
+ if (_low_value == TYPE_MAX) {
is_empty = true;
} else {
++_low_value;
}
}
+
if (!is_end_include()) {
- if (_high_value == TYPE_MAX) {
+ if (_high_value == TYPE_MIN) {
is_empty = true;
} else {
--_high_value;
diff --git a/regression-test/data/query_p0/scan_range/test_scan_range.out
b/regression-test/data/query_p0/scan_range/test_scan_range.out
new file mode 100644
index 00000000000..e4df16ef06c
--- /dev/null
+++ b/regression-test/data/query_p0/scan_range/test_scan_range.out
@@ -0,0 +1,10 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql_1 --
+1
+
+-- !sql_2 --
+1
+
+-- !sql_3 --
+
+-- !sql_4 --
diff --git a/regression-test/suites/query_p0/scan_range/test_scan_range.groovy
b/regression-test/suites/query_p0/scan_range/test_scan_range.groovy
new file mode 100644
index 00000000000..e011a5095a5
--- /dev/null
+++ b/regression-test/suites/query_p0/scan_range/test_scan_range.groovy
@@ -0,0 +1,45 @@
+// 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_scan_range", "query,p0") {
+
+ sql "use test_query_db"
+
+ def tableName = "test_scan_range_tbl"
+
+ sql """
+ CREATE TABLE `${tableName}` (
+ `k1` INT NULL,
+ `k2` INT NULL
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`k1`, `k2`)
+ DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ );
+ """
+
+ sql "insert into ${tableName} values(1,1)"
+
+ qt_sql_1 "select k1 from ${tableName} where k1 > -2147483648"
+
+ qt_sql_2 "select k1 from ${tableName} where k1 < 2147483647"
+
+ qt_sql_3 "select k1 from ${tableName} where k1 < -2147483648"
+
+ qt_sql_4 "select k1 from ${tableName} where k1 > 2147483647"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]