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

Optimization can change column name for group by since 23.5 #55024

Closed
Arvamer opened this issue Sep 26, 2023 · 2 comments
Closed

Optimization can change column name for group by since 23.5 #55024

Arvamer opened this issue Sep 26, 2023 · 2 comments
Labels
bug Confirmed user-visible misbehaviour in official release duplicate

Comments

@Arvamer
Copy link

Arvamer commented Sep 26, 2023

https://fiddle.clickhouse.com/80c8bea6-1952-499b-91bc-6a08d34355cc

SELECT if(true, null, name) as foo, count(*)
FROM users
GROUP BY foo;

Running this query will result in following error;

Column name is not under aggregate function and not in GROUP BY. Have columns: ['NULL','true','count()']

Query works fine in 23.4. This only happens with const condition in if. After changing true to something that depends on data from table like name is not null query will be executed without any errors.

Expected behavior

Query is valid and should group by result of if (true, null, name).

@Arvamer Arvamer added the potential bug To be reviewed by developers and confirmed/rejected. label Sep 26, 2023
@den-crane den-crane added bug Confirmed user-visible misbehaviour in official release and removed potential bug To be reviewed by developers and confirmed/rejected. labels Sep 26, 2023
@den-crane
Copy link
Contributor

den-crane commented Sep 26, 2023

you can use materialize(true) as a workaround
or if (1, null, name)

@den-crane
Copy link
Contributor

duplicate #50928 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release duplicate
Projects
None yet
Development

No branches or pull requests

2 participants