Fix optimize_aggregation_in_order in case of empty result set

Note, that this is not complete fix, see the next two patches.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2022-01-14 15:47:26 +03:00
parent f3359b4698
commit d9a64d1f86
3 changed files with 27 additions and 1 deletions

View File

@ -23,7 +23,11 @@ void MergingAggregatedTransform::consume(Chunk chunk)
LOG_TRACE(log, "Reading blocks of partially aggregated data.");
}
total_input_rows += chunk.getNumRows();
size_t input_rows = chunk.getNumRows();
if (!input_rows)
return;
total_input_rows += input_rows;
++total_input_blocks;
const auto & info = chunk.getChunkInfo();

View File

@ -0,0 +1,8 @@
-- { echoOn }
-- regression for optimize_aggregation_in_order with empty result set
-- that cause at first
-- "Chunk should have AggregatedChunkInfo in GroupingAggregatedTransform"
-- at first and after
-- "Chunk should have AggregatedChunkInfo in GroupingAggregatedTransform"
select count() from remote('127.{1,2}', currentDatabase(), data_02176) where key = 0 group by key settings optimize_aggregation_in_order=1;

View File

@ -0,0 +1,14 @@
drop table if exists data_02176;
create table data_02176 (key Int) Engine=MergeTree() order by key;
-- { echoOn }
-- regression for optimize_aggregation_in_order with empty result set
-- that cause at first
-- "Chunk should have AggregatedChunkInfo in GroupingAggregatedTransform"
-- at first and after
-- "Chunk should have AggregatedChunkInfo in GroupingAggregatedTransform"
select count() from remote('127.{1,2}', currentDatabase(), data_02176) where key = 0 group by key settings optimize_aggregation_in_order=1;
-- { echoOff }
drop table data_02176;