This is an automated email from the ASF dual-hosted git repository.
zhangstar333 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 722fabe0010 [Bug](compatibility) fix percentile function coredump when
upgrade (#39330)
722fabe0010 is described below
commit 722fabe001040a94f889f536d3aa5e7472b53ff3
Author: zhangstar333 <[email protected]>
AuthorDate: Thu Sep 19 18:26:53 2024 +0800
[Bug](compatibility) fix percentile function coredump when upgrade (#39330)
## Proposed changes
if the inited_flag == false, should not write buf,
as the write function will write two std::vector,
but in read function, use the size_num from vec_quantile vector,
if not have inited, the size of two vector maybe not equal.
<!--Describe your changes.-->
---
be/src/vec/aggregate_functions/aggregate_function_percentile.cpp | 4 ++--
be/src/vec/aggregate_functions/aggregate_function_percentile.h | 8 +++++++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/be/src/vec/aggregate_functions/aggregate_function_percentile.cpp
b/be/src/vec/aggregate_functions/aggregate_function_percentile.cpp
index 00034776607..b0da562bd73 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_percentile.cpp
+++ b/be/src/vec/aggregate_functions/aggregate_function_percentile.cpp
@@ -33,8 +33,8 @@ AggregateFunctionPtr
create_aggregate_function_percentile_approx_older(
}
if (argument_types.size() == 2) {
return creator_without_type::create<
-
AggregateFunctionPercentileApproxTwoParams_OLDER<is_nullable>>((argument_types),
-
result_is_nullable);
+ AggregateFunctionPercentileApproxTwoParams_OLDER<is_nullable>>(
+ remove_nullable(argument_types), result_is_nullable);
}
if (argument_types.size() == 3) {
return creator_without_type::create<
diff --git a/be/src/vec/aggregate_functions/aggregate_function_percentile.h
b/be/src/vec/aggregate_functions/aggregate_function_percentile.h
index cd328a85f34..1c8a12340d7 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_percentile.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_percentile.h
@@ -583,11 +583,14 @@ public:
template <typename T>
struct PercentileState {
mutable std::vector<Counts<T>> vec_counts;
- std::vector<double> vec_quantile;
+ std::vector<double> vec_quantile {-1};
bool inited_flag = false;
void write(BufferWritable& buf) const {
write_binary(inited_flag, buf);
+ if (!inited_flag) {
+ return;
+ }
int size_num = vec_quantile.size();
write_binary(size_num, buf);
for (const auto& quantile : vec_quantile) {
@@ -600,6 +603,9 @@ struct PercentileState {
void read(BufferReadable& buf) {
read_binary(inited_flag, buf);
+ if (!inited_flag) {
+ return;
+ }
int size_num = 0;
read_binary(size_num, buf);
double data = 0.0;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]