mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Merge pull request #25055 from amosbird/projection-fix9
Fix using aggregate projection when group by without key
This commit is contained in:
commit
ab2529d4f0
@ -1894,11 +1894,11 @@ void NO_INLINE Aggregator::mergeWithoutKeyStreamsImpl(
|
||||
res = place;
|
||||
}
|
||||
|
||||
if (block.rows() > 0)
|
||||
for (size_t row = 0, rows = block.rows(); row < rows; ++row)
|
||||
{
|
||||
/// 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);
|
||||
aggregate_functions[i]->merge(res + offsets_of_aggregate_states[i], (*aggregate_columns[i])[row], result.aggregates_pool);
|
||||
}
|
||||
|
||||
/// Early release memory.
|
||||
|
@ -234,7 +234,6 @@ QueryPlanPtr MergeTreeDataSelectExecutor::read(
|
||||
select.setExpression(ASTSelectQuery::Expression::WHERE, given_select.where()->clone());
|
||||
if (given_select.prewhere())
|
||||
select.setExpression(ASTSelectQuery::Expression::WHERE, given_select.prewhere()->clone());
|
||||
// TODO will row policy filter work?
|
||||
|
||||
// After overriding the group by clause, we finish the possible aggregations directly
|
||||
if (processed_stage >= QueryProcessingStage::Enum::WithMergeableState && given_select.groupBy())
|
||||
|
@ -0,0 +1,2 @@
|
||||
499500
|
||||
499500
|
@ -0,0 +1,8 @@
|
||||
drop table if exists projection_without_key;
|
||||
|
||||
create table projection_without_key (key UInt32, PROJECTION x (SELECT sum(key) group by key % 3)) engine MergeTree order by key;
|
||||
insert into projection_without_key select number from numbers(1000);
|
||||
select sum(key) from projection_without_key settings allow_experimental_projection_optimization = 1;
|
||||
select sum(key) from projection_without_key settings allow_experimental_projection_optimization = 0;
|
||||
|
||||
drop table projection_without_key;
|
Loading…
Reference in New Issue
Block a user