Closed
Description
You have to provide the following information whenever possible.
Wrong behavior for the filter using prefer_column_name_to_alias = 1
CREATE TABLE loans (loan_number int, security_id text) ENGINE=Memory;
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
with block_0 as (
select * from loans
),
block_1 as (
select sum(loan_number) as loan_number from block_0 group by security_id
)
select loan_number from block_1 where loan_number > 3 settings prefer_column_name_to_alias = 1
In this query filter loan_number > 3 for some reason will not operate on the aggregation.
By the logic original column name here should not be available, as the context after aggregation should be different and alias should be used.
A link to reproducer in https://fiddle.clickhouse.com/.
Does it reproduce on recent release?
yes
Expected behavior
A clear and concise description of what you expected to happen.
Expected output for the query above is
5
6
Please help with this bug.
Activity
Closes: #54954