Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 2 additions & 18 deletions be/src/vec/aggregate_functions/aggregate_function_array_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,7 @@ struct AggregateFunctionArrayAggData {
}

void merge(const Self& rhs) {
const auto size = rhs.null_map->size();
null_map->resize(size);
nested_column->reserve(size);
for (size_t i = 0; i < size; i++) {
const auto null_value = rhs.null_map->data()[i];
const auto data_value = rhs.nested_column->get_data()[i];
null_map->data()[i] = null_value;
nested_column->get_data().push_back(data_value);
}
column_data->insert_range_from(*rhs.column_data, 0, rhs.column_data->size());
}
};

Expand Down Expand Up @@ -229,15 +221,7 @@ struct AggregateFunctionArrayAggData<T> {
}

void merge(const Self& rhs) {
const auto size = rhs.null_map->size();
null_map->resize(size);
nested_column->reserve(size);
for (size_t i = 0; i < size; i++) {
const auto null_value = rhs.null_map->data()[i];
auto s = rhs.nested_column->get_data_at(i);
null_map->data()[i] = null_value;
nested_column->insert_data(s.data, s.size);
}
column_data->insert_range_from(*rhs.column_data, 0, rhs.column_data->size());
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void register_aggregate_function_combinator_foreachv2(AggregateFunctionSimpleFac
for (const auto& t : types) {
auto item_type =
assert_cast<const DataTypeArray*>(remove_nullable(t).get())->get_nested_type();
transform_arguments.push_back((item_type));
transform_arguments.push_back(item_type);
}
auto nested_function_name = name.substr(0, name.size() - suffix.size());
auto nested_function = factory.get(nested_function_name, transform_arguments, true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
[null, 1, 2, 2, 3, 20, 100]

-- !sql --
[null, "114514", "123", "ab", "c", "cd", "efg"]

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

suite("test_agg_foreach_multi_instance") {
sql """
drop table if exists foreach_table_m;
"""

sql """
CREATE TABLE IF NOT EXISTS foreach_table_m (
`id` INT(11) null COMMENT "",
`a` array<INT> null COMMENT "",
`b` array<array<INT>> null COMMENT "",
`s` array<String> null COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`id`)
DISTRIBUTED BY HASH(`id`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"storage_format" = "V2"
);
"""
sql """
insert into foreach_table_m values
(1,[1,2,3],[[1],[1,2,3],[2]],["ab","123","114514"]),
(2,[20],[[2]],["cd"]),
(3,[100],[[1]],["efg"]) ,
(4,null,[null],null),
(5,[null,2],[[2],null],[null,'c']);
"""
qt_sql """select array_sort(array_flatten(array_agg_foreach(a))) from foreach_table_m;"""
qt_sql """select array_sort(array_flatten(array_agg_foreach(s))) from foreach_table_m;"""
}
Loading