From f2fa9606c9bdee42568286e634d3061db3f6ff38 Mon Sep 17 00:00:00 2001 From: starocean999 <40539150+starocean999@users.noreply.github.com> Date: Sat, 15 Oct 2022 10:40:52 +0800 Subject: [PATCH] [fix](agg)count function should return 0 for null value (#13247) count(null) should return 0 instead of 1, the streaming_agg_serialize_to_column function didn't handle if the input value is null, this pr fix it. --- be/src/vec/aggregate_functions/aggregate_function_count.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/be/src/vec/aggregate_functions/aggregate_function_count.h b/be/src/vec/aggregate_functions/aggregate_function_count.h index 8ab6b53e56..883a3b5c23 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_count.h +++ b/be/src/vec/aggregate_functions/aggregate_function_count.h @@ -189,7 +189,11 @@ public: const size_t num_rows, Arena* arena) const override { auto& col = assert_cast(*dst); col.resize(num_rows); - col.get_data().assign(num_rows, 1UL); + auto& data = col.get_data(); + const ColumnNullable& input_col = assert_cast(*columns[0]); + for (size_t i = 0; i < num_rows; i++) { + data[i] = !input_col.is_null_at(i); + } } void deserialize_and_merge_from_column(AggregateDataPtr __restrict place, const IColumn& column,