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
Unknown identifier in aggregate function error when using same alias in different levels of query #28777
When same alias names are used in different levels of query in some cases "unknown identifier" errors are received.
Does it reproduce on recent release?
Yes, reproduces on all builds 21.3, 21.8, latest 21.9 too.
How to reproduce
chserver :) SELECT
:-] sum(q0.a2) AS a1,
:-] sum(q0.a1) AS a9
:-] FROM
:-] (
:-] SELECT
:-] 1 AS a1,
:-] 2 AS a2
:-] ) AS q0
:-] ;
SELECT
sum(q0.a2) AS a1,
sum(q0.a1) AS a9
FROM
(
SELECT
1 AS a1,
2 AS a2
) AS q0
Query id: cd2ff574-fcb3-4027-8fee-7a105bccde53
Received exception from server (version 21.8.5):
Code: 47. DB::Exception: Received from chserver:9000. DB::Exception: Unknown identifier 'a1' in aggregate function 'sum(a1) AS a9'.
0 rows in set. Elapsed: 0.121 sec.
chserver :) SELECT
:-] (q0.a2) AS a1,
:-] (q0.a1) AS a9
:-] FROM
:-] (
:-] SELECT
:-] 1 AS a1,
:-] 2 AS a2
:-] ) AS q0
:-] ;
SELECT
q0.a2 AS a1,
q0.a1 AS a9
FROM
(
SELECT
1 AS a1,
2 AS a2
) AS q0
Query id: ec6a030a-d8e2-4ad1-b7de-35bb74831ba6
┌─a1─┬─a9─┐
│ 2 │ 1 │
└────┴────┘
1 rows in set. Elapsed: 0.121 sec.
chserver :)
Expected behavior
It should work disregarding of order of columns in query.
Activity
alexey-milovidov commentedon Jan 18, 2022
Hold until #23194 is implemented.
Close: #28777