Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleAggregateFunction(groupUniqArrayArray is merged incorrectly in SummingMergeTree #18676

Closed
den-crane opened this issue Dec 31, 2020 · 1 comment · Fixed by #18677
Closed
Labels
bug-unreleased Bug that affects unreleased or experimental code

Comments

@den-crane
Copy link
Contributor

cat w.sql
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;

clickhouse-client -mn <w.sql
[0,1]	[0]

EXPECTED:
[0,1]	[0,1]

AggregateFunction(groupUniqArrayArray & SimpleAggregateFunction(groupUniqArrayArray have to produce the same result [0,1]

Let's replace SummingMergeTree engine to AggregatingMergeTree:

cat ww.sql
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 = AggregatingMergeTree() 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

cat ww.sql |clickhouse-client -mn
[0,1]	[0,1]
@den-crane den-crane added bug Confirmed user-visible misbehaviour in official release bug-unreleased Bug that affects unreleased or experimental code and removed bug Confirmed user-visible misbehaviour in official release labels Dec 31, 2020
@den-crane
Copy link
Contributor Author

@amosbird

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-unreleased Bug that affects unreleased or experimental code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant