mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Merge pull request #18818 from templarzq/master
Implement ColumnAggregateFunction cloneResized method
This commit is contained in:
commit
e914ef619f
@ -670,4 +670,32 @@ ColumnAggregateFunction::ColumnAggregateFunction(const ColumnAggregateFunction &
|
||||
{
|
||||
}
|
||||
|
||||
MutableColumnPtr ColumnAggregateFunction::cloneResized(size_t size) const
|
||||
{
|
||||
if (size == 0)
|
||||
return cloneEmpty();
|
||||
|
||||
size_t from_size = data.size();
|
||||
|
||||
if (size <= from_size)
|
||||
{
|
||||
auto res = createView();
|
||||
auto & res_data = res->data;
|
||||
res_data.assign(data.begin(), data.begin() + size);
|
||||
return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Create a new column to return.
|
||||
MutableColumnPtr cloned_col = cloneEmpty();
|
||||
auto * res = typeid_cast<ColumnAggregateFunction *>(cloned_col.get());
|
||||
|
||||
res->insertRangeFrom(*this, 0, from_size);
|
||||
for (size_t i = from_size; i < size; ++i)
|
||||
res->insertDefault();
|
||||
|
||||
return cloned_col;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public:
|
||||
void getExtremes(Field & min, Field & max) const override;
|
||||
|
||||
bool structureEquals(const IColumn &) const override;
|
||||
|
||||
MutableColumnPtr cloneResized(size_t size) const override;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
1 1
|
57
tests/queries/0_stateless/01552_impl_aggfunc_cloneresize.sql
Normal file
57
tests/queries/0_stateless/01552_impl_aggfunc_cloneresize.sql
Normal file
@ -0,0 +1,57 @@
|
||||
drop table if EXISTS test_bm;
|
||||
|
||||
drop table if EXISTS test_bm_join;
|
||||
|
||||
create table test_bm(
|
||||
dim UInt64,
|
||||
id UInt64 )
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY( dim, id )
|
||||
SETTINGS index_granularity = 8192;
|
||||
|
||||
create table test_bm_join(
|
||||
dim UInt64,
|
||||
id UInt64 )
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY(dim,id)
|
||||
SETTINGS index_granularity = 8192;
|
||||
|
||||
insert into test_bm VALUES (1,1),(2,2),(3,3),(4,4);
|
||||
|
||||
select
|
||||
dim ,
|
||||
sum(idnum)
|
||||
from
|
||||
test_bm_join
|
||||
right join(
|
||||
select
|
||||
dim,
|
||||
bitmapOrCardinality(ids,ids2) as idnum
|
||||
from
|
||||
(
|
||||
select
|
||||
dim,
|
||||
groupBitmapState(toUInt64(id)) as ids
|
||||
FROM
|
||||
test_bm
|
||||
where
|
||||
dim >2
|
||||
group by
|
||||
dim ) A all
|
||||
right join (
|
||||
select
|
||||
dim,
|
||||
groupBitmapState(toUInt64(id)) as ids2
|
||||
FROM
|
||||
test_bm
|
||||
where
|
||||
dim < 2
|
||||
group by
|
||||
dim ) B
|
||||
using(dim) ) C
|
||||
using(dim)
|
||||
group by dim;
|
||||
|
||||
drop table test_bm;
|
||||
|
||||
drop table test_bm_join;
|
@ -183,3 +183,4 @@
|
||||
01636_nullable_fuzz2
|
||||
01639_distributed_sync_insert_zero_rows
|
||||
01644_distributed_async_insert_fsync_smoke
|
||||
01552_impl_aggfunc_cloneresize
|
||||
|
Loading…
Reference in New Issue
Block a user