Fix empty key

This commit is contained in:
Amos Bird 2021-05-14 22:26:09 +08:00
parent 8de016d33a
commit a113acc40c
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
5 changed files with 21 additions and 5 deletions

View File

@ -1894,9 +1894,12 @@ void NO_INLINE Aggregator::mergeWithoutKeyStreamsImpl(
res = place;
}
/// Adding Values
for (size_t i = 0; i < params.aggregates_size; ++i)
aggregate_functions[i]->merge(res + offsets_of_aggregate_states[i], (*aggregate_columns[i])[0], result.aggregates_pool);
if (block.rows() > 0)
{
/// Adding Values
for (size_t i = 0; i < params.aggregates_size; ++i)
aggregate_functions[i]->merge(res + offsets_of_aggregate_states[i], (*aggregate_columns[i])[0], result.aggregates_pool);
}
/// Early release memory.
block.clear();

View File

@ -546,7 +546,12 @@ void AggregatingTransform::initGenerate()
/// If there was no data, and we aggregate without keys, and we must return single row with the result of empty aggregation.
/// To do this, we pass a block with zero rows to aggregate.
if (variants.empty() && params->params.keys_size == 0 && !params->params.empty_result_for_aggregation_by_empty_set)
params->aggregator.executeOnBlock(getInputs().front().getHeader(), variants, key_columns, aggregate_columns, no_more_keys);
{
if (params->only_merge)
params->aggregator.mergeBlock(getInputs().front().getHeader(), variants, no_more_keys);
else
params->aggregator.executeOnBlock(getInputs().front().getHeader(), variants, key_columns, aggregate_columns, no_more_keys);
}
double elapsed_seconds = watch.elapsedSeconds();
size_t rows = variants.sizeWithoutOverflowRow();

View File

@ -161,7 +161,11 @@ QueryPlanPtr MergeTreeDataSelectExecutor::read(
query_info.merge_tree_data_select_cache.get());
}
LOG_DEBUG(log, "Choose projection {}", query_info.projection->desc->name);
LOG_DEBUG(
log,
"Choose {} projection {}",
ProjectionDescription::typeToString(query_info.projection->desc->type),
query_info.projection->desc->name);
if (query_info.projection->merge_tree_data_select_base_cache->sum_marks
+ query_info.projection->merge_tree_data_select_projection_cache->sum_marks

View File

@ -3,4 +3,5 @@
2020-10-24 00:00:00 1.3619605237696326 0.16794469697335793 0.7637956767025532 0.8899329799574005 0.6227685185389797 0.30795997278638165 0.7637956767025532
2020-10-24 00:00:00 19 -1.9455094931672063 0.7759802460082872 0.6 0
2020-10-24 00:00:00 852 894
2 -1
999

View File

@ -38,6 +38,9 @@ select toStartOfMinute(datetime) dt_m, domain, sum(retry_count) / sum(duration),
select toStartOfHour(toStartOfMinute(datetime)) dt_h, uniqHLL12(x_id), uniqHLL12(y_id) from projection_test group by dt_h order by dt_h;
-- found by fuzzer
SELECT 2, -1 FROM projection_test PREWHERE domain_alias = 1. WHERE domain = NULL GROUP BY -9223372036854775808 ORDER BY countIf(first_time = 0) / count(-2147483649) DESC NULLS LAST, 1048576 DESC NULLS LAST;
drop table if exists projection_test;
drop table if exists projection_without_key;