xingyingone commented on code in PR #23474: URL: https://github.com/apache/doris/pull/23474#discussion_r1308469617
########## be/src/vec/aggregate_functions/aggregate_function_collect.cpp: ########## @@ -27,21 +27,25 @@ namespace doris::vectorized { -template <typename T, typename HasLimit> +template <typename T, typename HasLimit, typename ShowNull> AggregateFunctionPtr do_create_agg_function_collect(bool distinct, const DataTypes& argument_types, const bool result_is_nullable) { - if (distinct) { - return creator_without_type::create< - AggregateFunctionCollect<AggregateFunctionCollectSetData<T, HasLimit>, HasLimit>>( + if (ShowNull::value) { Review Comment: as below: //ShowNull is just used to support array_agg because array_agg needs to display NULL //todo: Supports order by sorting for array_agg ########## be/src/vec/aggregate_functions/aggregate_function_collect.h: ########## @@ -282,30 +304,53 @@ struct AggregateFunctionCollectListData<StringRef, HasLimit> { void reset() { data->clear(); } - void insert_result_into(IColumn& to) const { - auto& to_str = assert_cast<ColVecType&>(to); - to_str.insert_range_from(*data, 0, size()); + void insert_result_into(IColumn& to, bool shownull = false) const { + if (shownull == false) { + auto& to_str = assert_cast<ColVecType&>(to); + to_str.insert_range_from(*data, 0, size()); + } else { + auto& to_arr = assert_cast<ColumnArray&>(to); + auto& to_nested_col = to_arr.get_data(); + size_t num_rows = data->size(); + DCHECK(to_nested_col.is_nullable()); + auto col_null = reinterpret_cast<ColumnNullable*>(&to_nested_col); + for (size_t i = 0; i < num_rows; ++i) { + auto column = data->get_data_at(i); + assert_cast<ColVecType&>(col_null->get_nested_column()) + .insert_data(column.data, column.size); + if (column.data == NULL || column.size == 0) { + col_null->get_null_map_data().push_back(1); + } else { + col_null->get_null_map_data().push_back(0); + } + } + to_arr.get_offsets().push_back(to_nested_col.size()); + } } }; -template <typename Data, typename HasLimit> +template <typename Data, typename HasLimit, typename ShowNull> Review Comment: okas below: //ShowNull is just used to support array_agg because array_agg needs to display NULL //todo: Supports order by sorting for array_agg -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org