This is an automated email from the ASF dual-hosted git repository.
panxiaolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 115c6bd411 [fix](keyranges) fix the split error of keyranges (#14049)
115c6bd411 is described below
commit 115c6bd411a98b917f229c78a300450ddf6e5e99
Author: luozenglin <[email protected]>
AuthorDate: Tue Nov 8 22:09:16 2022 +0800
[fix](keyranges) fix the split error of keyranges (#14049)
fix the split error of keyranges
---
be/src/exec/olap_common.h | 28 +++++++++++++---------
be/test/exec/olap_common_test.cpp | 2 +-
.../data/query_p0/aggregate/aggregate.out | 3 +++
.../suites/query_p0/aggregate/aggregate.groovy | 2 ++
4 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/be/src/exec/olap_common.h b/be/src/exec/olap_common.h
index aaa76f9246..8c470316bb 100644
--- a/be/src/exec/olap_common.h
+++ b/be/src/exec/olap_common.h
@@ -111,8 +111,8 @@ public:
void convert_to_range_value();
bool convert_to_avg_range_value(std::vector<OlapTuple>& begin_scan_keys,
- std::vector<OlapTuple>& end_scan_keys,
- int32_t max_scan_key_num);
+ std::vector<OlapTuple>& end_scan_keys,
bool& begin_include,
+ bool& end_include, int32_t
max_scan_key_num);
bool has_intersection(ColumnValueRange<primitive_type>& range);
@@ -516,7 +516,7 @@ size_t
ColumnValueRange<primitive_type>::get_convertible_fixed_value_size() cons
template <PrimitiveType primitive_type>
bool ColumnValueRange<primitive_type>::convert_to_avg_range_value(
std::vector<OlapTuple>& begin_scan_keys, std::vector<OlapTuple>&
end_scan_keys,
- int32_t max_scan_key_num) {
+ bool& begin_include, bool& end_include, int32_t max_scan_key_num) {
constexpr bool reject_type = primitive_type ==
PrimitiveType::TYPE_LARGEINT ||
primitive_type ==
PrimitiveType::TYPE_DECIMALV2 ||
primitive_type == PrimitiveType::TYPE_HLL ||
@@ -526,6 +526,8 @@ bool
ColumnValueRange<primitive_type>::convert_to_avg_range_value(
primitive_type == PrimitiveType::TYPE_BOOLEAN
||
primitive_type ==
PrimitiveType::TYPE_DATETIME ||
primitive_type ==
PrimitiveType::TYPE_DATETIMEV2;
+ begin_include = is_begin_include();
+ end_include = is_end_include();
if constexpr (reject_type) {
begin_scan_keys.emplace_back();
begin_scan_keys.back().add_value(
@@ -537,8 +539,14 @@ bool
ColumnValueRange<primitive_type>::convert_to_avg_range_value(
return true;
} else {
CppType current = get_range_min_value();
+ CppType max_value = get_range_max_value();
+ if (!is_begin_include() && !is_end_include() && current < TYPE_MAX &&
+ current + 1 < max_value) {
+ begin_include = true;
+ ++current;
+ }
- size_t range_size = get_convertible_fixed_value_size();
+ size_t range_size = is_fixed_value_convertible() ? max_value - current
: 0;
size_t step_size = std::max(
(range_size / max_scan_key_num) + (range_size %
max_scan_key_num != 0), (size_t)1);
@@ -546,13 +554,13 @@ bool
ColumnValueRange<primitive_type>::convert_to_avg_range_value(
current.set_type(TimeType::TIME_DATE);
}
- while (current < get_range_max_value()) {
+ while (current < max_value) {
begin_scan_keys.emplace_back();
begin_scan_keys.back().add_value(
cast_to_string<primitive_type, CppType>(current, scale()));
- if (get_range_max_value() - current < step_size) {
- current = get_range_max_value();
+ if (max_value - current < step_size) {
+ current = max_value;
} else {
current += step_size;
}
@@ -893,12 +901,10 @@ Status
OlapScanKeys::extend_scan_key(ColumnValueRange<primitive_type>& range,
}
} else {
if (_begin_scan_keys.empty() && range.is_fixed_value_convertible() &&
_is_convertible) {
- if (range.convert_to_avg_range_value(_begin_scan_keys,
_end_scan_keys,
- max_scan_key_num)) {
+ if (range.convert_to_avg_range_value(_begin_scan_keys,
_end_scan_keys, _begin_include,
+ _end_include,
max_scan_key_num)) {
_has_range_value = true;
}
- _begin_include = range.is_begin_include();
- _end_include = range.is_end_include();
return Status::OK();
}
}
diff --git a/be/test/exec/olap_common_test.cpp
b/be/test/exec/olap_common_test.cpp
index 9e77b3d455..e0056cad41 100644
--- a/be/test/exec/olap_common_test.cpp
+++ b/be/test/exec/olap_common_test.cpp
@@ -671,7 +671,7 @@ TEST_F(OlapScanKeysTest, EachtypeTest) {
scan_keys.get_key_range(&key_range);
EXPECT_EQ(key_range.size(), max_scan_key);
- EXPECT_EQ(OlapScanKeys::to_print_key(key_range[0]->begin_scan_range),
"0");
+ EXPECT_EQ(OlapScanKeys::to_print_key(key_range[0]->begin_scan_range),
"1");
EXPECT_EQ(OlapScanKeys::to_print_key(key_range[max_scan_key -
1]->end_scan_range), "32766");
}
}
diff --git a/regression-test/data/query_p0/aggregate/aggregate.out
b/regression-test/data/query_p0/aggregate/aggregate.out
index f571fd92a5..992e4cc4da 100644
--- a/regression-test/data/query_p0/aggregate/aggregate.out
+++ b/regression-test/data/query_p0/aggregate/aggregate.out
@@ -660,3 +660,6 @@ TESTING AGAIN
14 1 11011902 1
15 1 11011920 1
+-- !aggregate31 --
+15
+
diff --git a/regression-test/suites/query_p0/aggregate/aggregate.groovy
b/regression-test/suites/query_p0/aggregate/aggregate.groovy
index 513b98b34a..76abb4af0a 100644
--- a/regression-test/suites/query_p0/aggregate/aggregate.groovy
+++ b/regression-test/suites/query_p0/aggregate/aggregate.groovy
@@ -283,4 +283,6 @@ suite("aggregate") {
qt_aggregate_2phase_0"""select avg(distinct k1),avg(k2) from baseall"""
qt_aggregate_2phase_1"""select k1,count(distinct k2,k3),min(k4),count(*)
from baseall group by k1 order by k1"""
+
+ qt_aggregate31"select count(*) from baseall where k1 < 64 and k1 > 0;"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]