[BugFix](Array)Fix using Array aggregate function caused be coredump (#10649)
This commit is contained in:
@ -50,15 +50,13 @@ public:
|
||||
Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
|
||||
size_t result, size_t input_rows_count) override {
|
||||
const auto& typed_column = block.get_by_position(arguments[0]);
|
||||
auto ptr = typed_column.column->convert_to_full_column_if_const();
|
||||
const typename Impl::column_type* column_array;
|
||||
if (typed_column.column->is_nullable()) {
|
||||
if (ptr->is_nullable()) {
|
||||
column_array = check_and_get_column<const typename Impl::column_type>(
|
||||
static_cast<const ColumnNullable*>(typed_column.column.get())
|
||||
->get_nested_column_ptr()
|
||||
.get());
|
||||
static_cast<const ColumnNullable*>(ptr.get())->get_nested_column_ptr().get());
|
||||
} else {
|
||||
column_array = check_and_get_column<const typename Impl::column_type>(
|
||||
typed_column.column.get());
|
||||
column_array = check_and_get_column<const typename Impl::column_type>(ptr.get());
|
||||
}
|
||||
const auto* data_type_array =
|
||||
static_cast<const DataTypeArray*>(remove_nullable(typed_column.type).get());
|
||||
|
||||
@ -98,3 +98,14 @@ false
|
||||
-- !sql --
|
||||
\N
|
||||
|
||||
-- !sql --
|
||||
2
|
||||
|
||||
-- !sql --
|
||||
6
|
||||
|
||||
-- !sql --
|
||||
1
|
||||
|
||||
-- !sql --
|
||||
3
|
||||
|
||||
@ -59,4 +59,10 @@ suite("test_array_functions_by_literal", "all") {
|
||||
qt_sql "select [1,2,NULL][3]"
|
||||
qt_sql "select [1,2,NULL][2]"
|
||||
qt_sql "select [][-1]"
|
||||
|
||||
// array_aggregation function
|
||||
qt_sql "select array_avg([1,2,3])"
|
||||
qt_sql "select array_sum([1,2,3])"
|
||||
qt_sql "select array_min([1,2,3])"
|
||||
qt_sql "select array_max([1,2,3])"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user