mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Fix topK/topKWeighted merge (wtih non-default parameters)
This commit is contained in:
parent
1e80318b94
commit
0eac96972c
@ -64,7 +64,10 @@ public:
|
||||
|
||||
void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override
|
||||
{
|
||||
this->data(place).value.merge(this->data(rhs).value);
|
||||
auto & set = this->data(place).value;
|
||||
if (set.capacity() != reserved)
|
||||
set.resize(reserved);
|
||||
set.merge(this->data(rhs).value);
|
||||
}
|
||||
|
||||
void serialize(ConstAggregateDataPtr place, WriteBuffer & buf) const override
|
||||
@ -197,7 +200,10 @@ public:
|
||||
|
||||
void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override
|
||||
{
|
||||
this->data(place).value.merge(this->data(rhs).value);
|
||||
auto & set = this->data(place).value;
|
||||
if (set.capacity() != reserved)
|
||||
set.resize(reserved);
|
||||
set.merge(this->data(rhs).value);
|
||||
}
|
||||
|
||||
void insertResultInto(AggregateDataPtr place, IColumn & to, Arena *) const override
|
||||
|
6
tests/queries/0_stateless/01409_topK_merge.reference
Normal file
6
tests/queries/0_stateless/01409_topK_merge.reference
Normal file
@ -0,0 +1,6 @@
|
||||
AggregateFunctionTopK
|
||||
20
|
||||
20
|
||||
AggregateFunctionTopKGenericData
|
||||
20
|
||||
20
|
13
tests/queries/0_stateless/01409_topK_merge.sql
Normal file
13
tests/queries/0_stateless/01409_topK_merge.sql
Normal file
@ -0,0 +1,13 @@
|
||||
drop table if exists data_01409;
|
||||
create table data_01409 engine=Memory as select * from numbers(20);
|
||||
|
||||
-- easier to check merging via distributed tables
|
||||
-- but can be done vai topKMerge(topKState()) as well
|
||||
|
||||
select 'AggregateFunctionTopK';
|
||||
select length(topK(20)(number)) from remote('127.{1,1}', currentDatabase(), data_01409);
|
||||
select length(topKWeighted(20)(number, 1)) from remote('127.{1,1}', currentDatabase(), data_01409);
|
||||
|
||||
select 'AggregateFunctionTopKGenericData';
|
||||
select length(topK(20)((number, ''))) from remote('127.{1,1}', currentDatabase(), data_01409);
|
||||
select length(topKWeighted(20)((number, ''), 1)) from remote('127.{1,1}', currentDatabase(), data_01409);
|
Loading…
Reference in New Issue
Block a user