mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
Fix SimpleAggregateFunction in SummingMergeTree 2
This commit is contained in:
parent
4165a58ce4
commit
6a644b2af1
@ -215,8 +215,9 @@ static SummingSortedAlgorithm::ColumnsDefinition defineColumns(
|
|||||||
{
|
{
|
||||||
const ColumnWithTypeAndName & column = header.safeGetByPosition(i);
|
const ColumnWithTypeAndName & column = header.safeGetByPosition(i);
|
||||||
|
|
||||||
|
const auto * simple = dynamic_cast<const DataTypeCustomSimpleAggregateFunction *>(column.type->getCustomName());
|
||||||
/// Discover nested Maps and find columns for summation
|
/// Discover nested Maps and find columns for summation
|
||||||
if (typeid_cast<const DataTypeArray *>(column.type.get()))
|
if (typeid_cast<const DataTypeArray *>(column.type.get()) && !simple)
|
||||||
{
|
{
|
||||||
const auto map_name = Nested::extractTableName(column.name);
|
const auto map_name = Nested::extractTableName(column.name);
|
||||||
/// if nested table name ends with `Map` it is a possible candidate for special handling
|
/// if nested table name ends with `Map` it is a possible candidate for special handling
|
||||||
@ -231,7 +232,6 @@ static SummingSortedAlgorithm::ColumnsDefinition defineColumns(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool is_agg_func = WhichDataType(column.type).isAggregateFunction();
|
bool is_agg_func = WhichDataType(column.type).isAggregateFunction();
|
||||||
const auto * simple = dynamic_cast<const DataTypeCustomSimpleAggregateFunction *>(column.type->getCustomName());
|
|
||||||
|
|
||||||
/// There are special const columns for example after prewhere sections.
|
/// There are special const columns for example after prewhere sections.
|
||||||
if ((!column.type->isSummable() && !is_agg_func && !simple) || isColumnConst(*column.column))
|
if ((!column.type->isSummable() && !is_agg_func && !simple) || isColumnConst(*column.column))
|
||||||
|
@ -1 +1,2 @@
|
|||||||
([25],[1]) ([25],[1])
|
([25],[1]) ([25],[1])
|
||||||
|
[0,1] [0,1]
|
||||||
|
@ -7,3 +7,17 @@ insert into test_smt select id, sumMap(k), sumMapState(k) from (select 2 as id,
|
|||||||
select sumMap(sMap), sumMapMerge(aMap) from test_smt;
|
select sumMap(sMap), sumMapMerge(aMap) from test_smt;
|
||||||
|
|
||||||
drop table if exists test_smt;
|
drop table if exists test_smt;
|
||||||
|
|
||||||
|
drop table if exists simple_agf_summing_mt;
|
||||||
|
|
||||||
|
create table simple_agf_summing_mt (a Int64, grp_aggreg AggregateFunction(groupUniqArrayArray, Array(UInt64)), grp_simple SimpleAggregateFunction(groupUniqArrayArray, Array(UInt64))) engine = SummingMergeTree() order by a;
|
||||||
|
|
||||||
|
insert into simple_agf_summing_mt select 1 a, groupUniqArrayArrayState([toUInt64(number)]), groupUniqArrayArray([toUInt64(number)]) from numbers(1) group by a;
|
||||||
|
|
||||||
|
insert into simple_agf_summing_mt select 1 a, groupUniqArrayArrayState([toUInt64(number)]), groupUniqArrayArray([toUInt64(number)]) from numbers(2) group by a;
|
||||||
|
|
||||||
|
optimize table simple_agf_summing_mt final;
|
||||||
|
|
||||||
|
SELECT arraySort(groupUniqArrayArrayMerge(grp_aggreg)) gra , arraySort(groupUniqArrayArray(grp_simple)) grs FROM simple_agf_summing_mt group by a;
|
||||||
|
|
||||||
|
drop table if exists simple_agf_summing_mt;
|
||||||
|
Loading…
Reference in New Issue
Block a user