This is an automated email from the ASF dual-hosted git repository. lihaopeng 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 e21b949719e [Fix](bug) Is null predicate get error query result (#41702) e21b949719e is described below commit e21b949719ed39413b5dd172cb937b517fcb5d40 Author: HappenLee <happen...@hotmail.com> AuthorDate: Sat Oct 12 13:17:54 2024 +0800 [Fix](bug) Is null predicate get error query result (#41702) cherry-pick from #41668 --- be/src/exec/olap_common.h | 28 +++++++++++++--------- .../data/query_p0/scan_range/test_scan_range.out | 5 ++++ .../query_p0/scan_range/test_scan_range.groovy | 5 ++++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/be/src/exec/olap_common.h b/be/src/exec/olap_common.h index d66cde2fad3..8915c890f1e 100644 --- a/be/src/exec/olap_common.h +++ b/be/src/exec/olap_common.h @@ -722,6 +722,18 @@ bool ColumnValueRange<primitive_type>::convert_to_avg_range_value( std::vector<OlapTuple>& begin_scan_keys, std::vector<OlapTuple>& end_scan_keys, bool& begin_include, bool& end_include, int32_t max_scan_key_num) { if constexpr (!_is_reject_split_type) { + CppType min_value = get_range_min_value(); + CppType max_value = get_range_max_value(); + if constexpr (primitive_type == PrimitiveType::TYPE_DATE) { + min_value.set_type(TimeType::TIME_DATE); + max_value.set_type(TimeType::TIME_DATE); + } + auto empty_range_only_null = min_value > max_value; + if (empty_range_only_null) { + // Not contain null will be disposed in `convert_to_close_range`, return eos. + DCHECK(contain_null()); + } + auto no_split = [&]() -> bool { begin_scan_keys.emplace_back(); begin_scan_keys.back().add_value( @@ -729,18 +741,11 @@ bool ColumnValueRange<primitive_type>::convert_to_avg_range_value( contain_null()); end_scan_keys.emplace_back(); end_scan_keys.back().add_value( - cast_to_string<primitive_type, CppType>(get_range_max_value(), scale())); + cast_to_string<primitive_type, CppType>(get_range_max_value(), scale()), + empty_range_only_null ? true : false); return true; }; - - CppType min_value = get_range_min_value(); - CppType max_value = get_range_max_value(); - if constexpr (primitive_type == PrimitiveType::TYPE_DATE) { - min_value.set_type(TimeType::TIME_DATE); - max_value.set_type(TimeType::TIME_DATE); - } - - if (min_value > max_value || max_scan_key_num == 1) { + if (empty_range_only_null || max_scan_key_num == 1) { return no_split(); } @@ -1125,7 +1130,8 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<primitive_type>& range, *eos |= range.convert_to_close_range(_begin_scan_keys, _end_scan_keys, _begin_include, _end_include); - if (range.convert_to_avg_range_value(_begin_scan_keys, _end_scan_keys, _begin_include, + if (!(*eos) && + range.convert_to_avg_range_value(_begin_scan_keys, _end_scan_keys, _begin_include, _end_include, max_scan_key_num)) { _has_range_value = true; } 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 index e4df16ef06c..9d42dd67dc9 100644 --- a/regression-test/data/query_p0/scan_range/test_scan_range.out +++ b/regression-test/data/query_p0/scan_range/test_scan_range.out @@ -4,7 +4,12 @@ -- !sql_2 -- 1 +-2147483648 -- !sql_3 -- -- !sql_4 -- + +-- !sql_5 -- +\N + 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 index e011a5095a5..c0ec6daeef0 100644 --- a/regression-test/suites/query_p0/scan_range/test_scan_range.groovy +++ b/regression-test/suites/query_p0/scan_range/test_scan_range.groovy @@ -34,6 +34,8 @@ suite("test_scan_range", "query,p0") { """ sql "insert into ${tableName} values(1,1)" + sql "insert into ${tableName} values(-2147483648, -2147483648)" + sql "insert into ${tableName} values(null, null)" qt_sql_1 "select k1 from ${tableName} where k1 > -2147483648" @@ -42,4 +44,7 @@ suite("test_scan_range", "query,p0") { qt_sql_3 "select k1 from ${tableName} where k1 < -2147483648" qt_sql_4 "select k1 from ${tableName} where k1 > 2147483647" + + qt_sql_5 "select k1 from ${tableName} where k1 is null" + } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org