From 52be833fd21d3289623ce4ae682f6537e438fb57 Mon Sep 17 00:00:00 2001 From: LiuNeng <1398775315@qq.com> Date: Tue, 25 Apr 2023 11:38:50 +0800 Subject: [PATCH] fix aggregate all key is null error --- src/Interpreters/Aggregator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Interpreters/Aggregator.cpp b/src/Interpreters/Aggregator.cpp index d6fbf072d054..eb4aef59f9a4 100644 --- a/src/Interpreters/Aggregator.cpp +++ b/src/Interpreters/Aggregator.cpp @@ -2102,6 +2102,8 @@ Aggregator::convertToBlockImplNotFinal(Method & method, Table & data, Arenas & a std::optional out_cols; std::optional shuffled_key_sizes; + size_t rows_in_current_block = 0; + auto init_out_cols = [&]() { out_cols = prepareOutputBlockColumns(params, aggregate_functions, getHeader(final), aggregates_pools, final, max_block_size); @@ -2115,6 +2117,8 @@ Aggregator::convertToBlockImplNotFinal(Method & method, Table & data, Arenas & a for (size_t i = 0; i < params.aggregates_size; ++i) out_cols->aggregate_columns_data[i]->push_back(data.getNullKeyData() + offsets_of_aggregate_states[i]); + ++rows_in_current_block; + data.getNullKeyData() = nullptr; data.hasNullKeyData() = false; } @@ -2126,7 +2130,6 @@ Aggregator::convertToBlockImplNotFinal(Method & method, Table & data, Arenas & a // should be invoked at least once, because null data might be the only content of the `data` init_out_cols(); - size_t rows_in_current_block = 0; data.forEachValue( [&](const auto & key, auto & mapped)