mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
Make topK return Enum for Enum types
This commit is contained in:
parent
c1d2d2d7f7
commit
15cddc3c6e
@ -100,7 +100,8 @@ AggregateFunctionPtr createAggregateFunctionTopK(const std::string & name, const
|
|||||||
threshold = k;
|
threshold = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
AggregateFunctionPtr res(createWithNumericType<AggregateFunctionTopK, is_weighted>(*argument_types[0], threshold, load_factor, argument_types, params));
|
AggregateFunctionPtr res(createWithNumericType<AggregateFunctionTopK, is_weighted>(
|
||||||
|
*argument_types[0], threshold, load_factor, argument_types, params));
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
res = AggregateFunctionPtr(createWithExtraTypes<is_weighted>(argument_types[0], threshold, load_factor, params));
|
res = AggregateFunctionPtr(createWithExtraTypes<is_weighted>(argument_types[0], threshold, load_factor, params));
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
DataTypePtr getReturnType() const override
|
DataTypePtr getReturnType() const override
|
||||||
{
|
{
|
||||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeNumber<T>>());
|
return std::make_shared<DataTypeArray>(this->argument_types[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override
|
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override
|
||||||
|
1
tests/queries/0_stateless/01353_topk_enum.reference
Normal file
1
tests/queries/0_stateless/01353_topk_enum.reference
Normal file
@ -0,0 +1 @@
|
|||||||
|
['test','world','hello','']
|
1
tests/queries/0_stateless/01353_topk_enum.sql
Normal file
1
tests/queries/0_stateless/01353_topk_enum.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
WITH CAST(round(sqrt(number)) % 4 AS Enum('' = 0, 'hello' = 1, 'world' = 2, 'test' = 3)) AS x SELECT topK(10)(x) FROM numbers(1000);
|
Loading…
Reference in New Issue
Block a user