Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug](compatibility) fix covar_samp function coredump when upgrade #41023

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions be/src/vec/aggregate_functions/aggregate_function_covar.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#pragma once

#include <glog/logging.h>

#include "agent/be_exec_version_manager.h"
#define POP true
#define NOTPOP false
Expand Down Expand Up @@ -195,12 +197,30 @@ class AggregateFunctionSampCovariance
this->data(place).add(columns[0], columns[1], row_num);
} else {
if constexpr (is_nullable) { //this if check could remove with old function
// nullable means at least one child is null.
// so here, maybe JUST ONE OF ups is null. so nullptr perhaps in ..._x or ..._y!
const auto* nullable_column_x = check_and_get_column<ColumnNullable>(columns[0]);
const auto* nullable_column_y = check_and_get_column<ColumnNullable>(columns[1]);
if (!nullable_column_x->is_null_at(row_num) &&
!nullable_column_y->is_null_at(row_num)) {
this->data(place).add(&nullable_column_x->get_nested_column(),
&nullable_column_y->get_nested_column(), row_num);

if (nullable_column_x && nullable_column_y) { // both nullable
if (!nullable_column_x->is_null_at(row_num) &&
!nullable_column_y->is_null_at(row_num)) {
this->data(place).add(&nullable_column_x->get_nested_column(),
&nullable_column_y->get_nested_column(), row_num);
}
} else if (nullable_column_x) { // x nullable
if (!nullable_column_x->is_null_at(row_num)) {
this->data(place).add(&nullable_column_x->get_nested_column(), columns[1],
row_num);
}
} else if (nullable_column_y) { // y nullable
if (!nullable_column_y->is_null_at(row_num)) {
this->data(place).add(columns[0], &nullable_column_y->get_nested_column(),
row_num);
}
} else {
throw Exception(ErrorCode::INTERNAL_ERROR,
"Nullable function {} get non-nullable columns!", get_name());
}
} else {
this->data(place).add(columns[0], columns[1], row_num);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
1
1.0

-- !sql --
-1.5
Expand All @@ -12,4 +12,8 @@
4.5

-- !sql --
1.666667
1.666666666666666

-- !notnull3 --
1.666666666666666

Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ suite("test_covar_samp") {
(4, 4, 4)
"""
qt_sql "select covar_samp(x,y) from test_covar_samp"

qt_notnull3 "select covar_samp(non_nullable(x), y) from test_covar_samp"
sql """ DROP TABLE IF EXISTS test_covar_samp """
}
Loading