From bcebad1d60898978c43715633b53a0e90a0bc57c Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Sat, 4 Apr 2020 18:37:31 +0300 Subject: [PATCH] Try fix aggregating. --- dbms/src/Processors/Merges/AggregatingSortedTransform.cpp | 4 ++-- dbms/src/Processors/Merges/AggregatingSortedTransform.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dbms/src/Processors/Merges/AggregatingSortedTransform.cpp b/dbms/src/Processors/Merges/AggregatingSortedTransform.cpp index 82859559fb3..67b1289c4cc 100644 --- a/dbms/src/Processors/Merges/AggregatingSortedTransform.cpp +++ b/dbms/src/Processors/Merges/AggregatingSortedTransform.cpp @@ -185,7 +185,7 @@ void AggregatingSortedTransform::merge() if (key_differs) { /// Write the simple aggregation result for the previous group. - if (merged_data.mergedRows() > 0) + if (merged_data.isGroupStarted()) { insertSimpleAggregationResult(); merged_data.insertRow(); @@ -227,7 +227,7 @@ void AggregatingSortedTransform::merge() } /// Write the simple aggregation result for the previous group. - if (merged_data.mergedRows() > 0) + if (merged_data.isGroupStarted()) { insertSimpleAggregationResult(); merged_data.insertRow(); diff --git a/dbms/src/Processors/Merges/AggregatingSortedTransform.h b/dbms/src/Processors/Merges/AggregatingSortedTransform.h index 7f32ed4eade..bb950a68257 100644 --- a/dbms/src/Processors/Merges/AggregatingSortedTransform.h +++ b/dbms/src/Processors/Merges/AggregatingSortedTransform.h @@ -63,10 +63,15 @@ private: { for (auto column_number : column_numbers) columns[column_number]->insertFrom(*raw_columns[column_number], row); + + is_group_started = true; } + bool isGroupStarted() const { return is_group_started; } + void insertRow() { + is_group_started = false; ++total_merged_rows; ++merged_rows; /// TODO: sum_blocks_granularity += block_size; @@ -81,6 +86,8 @@ private: for (auto & desc : def.columns_to_aggregate) desc.column = typeid_cast(columns[desc.column_number].get()); } + private: + bool is_group_started = false; }; ColumnsDefinition columns_definition;