Do not return empty blocks from ConvertingAggregatedToChunksTransform (#41152)

* impl

* add test

* update test
This commit is contained in:
Nikita Taranov 2022-09-16 21:54:36 +02:00 committed by GitHub
parent 6e77751581
commit 6f186d3dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 4 deletions

View File

@ -248,8 +248,11 @@ private:
throw Exception(ErrorCodes::LOGICAL_ERROR, "Some ready chunks expected");
auto & output = outputs.front();
output.push(std::move(single_level_chunks.back()));
auto chunk = std::move(single_level_chunks.back());
single_level_chunks.pop_back();
const auto has_rows = chunk.hasRows();
if (has_rows)
output.push(std::move(chunk));
if (finished && single_level_chunks.empty())
{
@ -257,7 +260,7 @@ private:
return Status::Finished;
}
return Status::PortFull;
return has_rows ? Status::PortFull : Status::Ready;
}
/// Read all sources and try to push current bucket.
@ -281,7 +284,10 @@ private:
if (!two_level_chunks[current_bucket_num])
return Status::NeedData;
output.push(std::move(two_level_chunks[current_bucket_num]));
auto chunk = std::move(two_level_chunks[current_bucket_num]);
const auto has_rows = chunk.hasRows();
if (has_rows)
output.push(std::move(chunk));
++current_bucket_num;
if (current_bucket_num == NUM_BUCKETS)
@ -291,7 +297,7 @@ private:
return Status::Finished;
}
return Status::PortFull;
return has_rows ? Status::PortFull : Status::Ready;
}
AggregatingTransformParamsPtr params;

View File

@ -0,0 +1,6 @@
┌─number─┐
│ 42 │
└────────┘
┌─number─┐
│ 42 │
└────────┘

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -ue
unset CLICKHOUSE_LOG_COMMENT
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
${CLICKHOUSE_CURL} \
$CLICKHOUSE_URL \
--get \
--data-urlencode "query=
select number
from numbers_mt(1e6)
where number = 42
group by number
settings max_threads = 10, max_bytes_before_external_group_by = 1, group_by_two_level_threshold = 1
format PrettyCompact"
${CLICKHOUSE_CURL} \
$CLICKHOUSE_URL \
--get \
--data-urlencode "query=
select number
from numbers_mt(1e6)
where number = 42
group by number
settings max_threads = 10, max_bytes_before_external_group_by = 0, group_by_two_level_threshold = 1
format PrettyCompact"