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
Missing columns: 'a' while processing query with more than 2 tables in cross join #22627
bugConfirmed user-visible misbehaviour in official releasecomp-joinsJOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla...
WITH
x AS
(
SELECT 1 AS a
),
xx AS
(
SELECT *
FROM x
, x AS x1
)
SELECT *
FROM xx
WHERE a = 1
Query id: f4fc159a-a136-4191-a0f0-c11c5ecdea74
┌─a─┬─x1.a─┐
│ 1 │ 1 │
└───┴──────┘
WITH
x AS
(
SELECT 1 AS a
),
xx AS
(
SELECT *
FROM x
, x AS x1
, x AS x2
)
SELECT *
FROM xx
WHERE a = 1
Query id: bee7bab0-1f6a-4f29-bab5-f3b845e7095d
0 rows in set. Elapsed: 0.004 sec.
Received exception from server (version 21.5.1):
Code: 47. DB::Exception: Received from localhost:9000. DB::Exception: Missing columns: 'a' while processing query: 'WITH x AS (SELECT 1 AS a), xx AS (SELECT * FROM x , x AS x1 , x AS x2) SELECT `x.a`, `x1.a`, `x2.a` FROM xx WHERE a = 1', required columns: 'x.a' 'x1.a' 'x2.a' 'a' 'x.a' 'x1.a' 'x2.a' 'a'.
Also reproducible with other join types than CROSS.
Example, reproducible on 21.3.4:
with example as (select toDate('2021-01-01') as date, 1 as node, 1 as user)
SELECT extra_data
FROM (
SELECT join1.*
FROM example
LEFT JOIN ( SELECT toDate('2021-01-01') as date, 1 as extra_data ) AS join1
ON example.date = join1.date
LEFT JOIN ( SELECT toDate('2021-01-01') as date ) AS join2
ON (example.date = join2.date)
)
Produces Missing columns: 'extra_data'. Removing the second JOIN appears to fix the issue.
Probably original query shouln't be valid, since we allow ambiguous identifier only for a single join and single_join_prefer_left_table=true
:) SELECT a FROM (SELECT 1 AS a) AS x, (SELECT 2 AS a) AS x1, (SELECT 3 AS a) AS x2
Received exception from server (version 24.7.1):
Code: 207. DB::Exception: Received from localhost:9000. DB::Exception: JOIN (SELECT 1 AS a FROM system.one) AS x, (SELECT 2 AS a FROM system.one) AS x1 ambiguous identifier 'a'. In scope SELECT a FROM (SELECT 1 AS a) AS x, (SELECT 2 AS a) AS x1, (SELECT 3 AS a) AS x2. (AMBIGUOUS_IDENTIFIER)
@UnamedRus do you think we can keep this behavior and keep original query with multiple joins illegal (effectively rolling back support of the query) ?
however, i find this "issue" because, it was expected behavior for someone, (at least, without that far simplication of query) May be, i can find source query.
Ok, it was opened, at the same time as #22626, which was made for TPC-DS benchmark investigation. I assume this is also related to it
bugConfirmed user-visible misbehaviour in official releasecomp-joinsJOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla...
Activity
adrian17 commentedon Apr 16, 2021
Also reproducible with other join types than CROSS.
Example, reproducible on 21.3.4:
Produces
Missing columns: 'extra_data'. Removing the second JOIN appears to fix the issue.alexey-milovidov commentedon Mar 20, 2023
Also works perfectly with the analyzer! Will be easy to close after the analyzer is merged.
Close: #22627
vdimir commentedon Jul 4, 2024
Probably original query shouln't be valid, since we allow ambiguous identifier only for a single join and
single_join_prefer_left_table=true@UnamedRus do you think we can keep this behavior and keep original query with multiple joins illegal (effectively rolling back support of the query) ?
UnamedRus commentedon Jul 4, 2024
It's not like big argument, but SQLite does support it in that form(MySQL and PostgreSQL doesn't)
https://www.db-fiddle.com/f/qM4vp4fu9m5DJ9pbE4CDdu/1
however, i find this "issue" because, it was expected behavior for someone, (at least, without that far simplication of query) May be, i can find source query.
Ok, it was opened, at the same time as #22626, which was made for TPC-DS benchmark investigation. I assume this is also related to it
alexey-milovidov commentedon Feb 7, 2026
Closing: explicitly fixed by commit
809461ccdaemerged into master. Test added via PR #62185.