You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The group by field is not correctly identified during aggregation query #32639
Describe what's wrong
The group by field is not correctly identified during aggregation query
Does it reproduce on recent release?
21.8.12.29-lts How to reproduce
Which ClickHouse server version to use
21.8.10.19-lts , 21.8.12.29-lts
create table groupby_test(id Int8)
engine=MergeTree
Order by tuple();
insert into groupby_test values (1),(2);
select multiIf(1=2 and id>0,1,2) as a ,sum(id) from groupby_test GROUP BY a;
Expected behavior
| 2 | 3 | Error message and/or stacktrace
Column id is not under aggregate function and not in GROUP BY: While processing mulitIf((1=2) AND id>0,1,2) as a,sum(id).
Activity
alexey-milovidov commentedon Dec 13, 2021
Minimal reproducing example:
KochetovNicolai commentedon Dec 15, 2021
My understanding what is going on:
0 AND id ? 1 : 2 AS ais detected as constantGROUP BYis removed becauseais constant and there issumfunctionSELECT 0 AND id ? 1 : 2 AS a, sum(id) FROM (SELECT 1 AS id)0 AND id ? 1 : 2 AS ais not a key and depend onidwhich is not under aggregate functionIt probably works for other cases if AST optimization can detect that expression (in case of
0 AND id ? 1 : 2 AS ait can't).I have no idea how to fix it.
The possible way - remove group-by-constant-key optimisation completely (or make it somewhere else)
Close: #32639