This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit fb28d0b18598360a6def809ae7df08a91edf5a10 Author: shee <13843187+qz...@users.noreply.github.com> AuthorDate: Tue May 21 10:59:07 2024 +0800 [BUG] fix scan range boundary handling is incorrect (#34832) fix scan range boundary handling is incorrect Co-authored-by: shizhiqiang03 <shizhiqian...@meituan.com> --- 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 5d6377b9c7c..46983c5390e 100644 --- a/be/src/exec/olap_common.h +++ b/be/src/exec/olap_common.h @@ -702,14 +702,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: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org