mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #18404 from amosbird/fixsimplestate
-SimpleState function arg type = return type
This commit is contained in:
commit
4561527d4d
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <AggregateFunctions/AggregateFunctionFactory.h>
|
||||
#include <AggregateFunctions/IAggregateFunction.h>
|
||||
#include <DataTypes/DataTypeCustomSimpleAggregateFunction.h>
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
@ -32,10 +33,17 @@ public:
|
||||
DataTypePtr getReturnType() const override
|
||||
{
|
||||
DataTypeCustomSimpleAggregateFunction::checkSupportedFunctions(nested_func);
|
||||
|
||||
// Need to make a clone because it'll be customized.
|
||||
auto storage_type = DataTypeFactory::instance().get(nested_func->getReturnType()->getName());
|
||||
|
||||
// Need to make a new function with promoted argument types because SimpleAggregates requires arg_type = return_type.
|
||||
AggregateFunctionProperties properties;
|
||||
auto function
|
||||
= AggregateFunctionFactory::instance().get(nested_func->getName(), {storage_type}, nested_func->getParameters(), properties);
|
||||
|
||||
DataTypeCustomNamePtr custom_name
|
||||
= std::make_unique<DataTypeCustomSimpleAggregateFunction>(nested_func, DataTypes{nested_func->getReturnType()}, params);
|
||||
= std::make_unique<DataTypeCustomSimpleAggregateFunction>(function, DataTypes{nested_func->getReturnType()}, params);
|
||||
storage_type->setCustomization(std::make_unique<DataTypeCustomDesc>(std::move(custom_name), nullptr));
|
||||
return storage_type;
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
1 10
|
||||
20 30
|
||||
40 110
|
||||
1 10
|
||||
20 60
|
||||
40 120
|
@ -0,0 +1,13 @@
|
||||
drop table if exists ay;
|
||||
|
||||
create table ay engine AggregatingMergeTree order by i as select 1 i, sumSimpleState(10) group by i;
|
||||
insert into ay values(40, 60);
|
||||
insert into ay values(40, 50);
|
||||
insert into ay values(20, 30);
|
||||
optimize table ay;
|
||||
select * from ay;
|
||||
insert into ay values(20, 30), (40, 10);
|
||||
optimize table ay;
|
||||
select * from ay;
|
||||
|
||||
drop table if exists ay;
|
Loading…
Reference in New Issue
Block a user