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

Missing columns: 'a' while processing query with more than 2 tables in cross join #22627

Closed
UnamedRus opened this issue Apr 4, 2021 · 2 comments · Fixed by #62185
Closed
Labels
bug Confirmed user-visible misbehaviour in official release comp-joins JOINs st-hold We've paused the work on issue for some reason

Comments

@UnamedRus
Copy link
Contributor

How to reproduce
Clickhouse 21.5

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'.
@UnamedRus UnamedRus added the bug Confirmed user-visible misbehaviour in official release label Apr 4, 2021
@adrian17
Copy link

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.

@alexey-milovidov alexey-milovidov added the st-hold We've paused the work on issue for some reason label Jun 17, 2021
@alexey-milovidov
Copy link
Member

Also works perfectly with the analyzer! Will be easy to close after the analyzer is merged.

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 comp-joins JOINs st-hold We've paused the work on issue for some reason
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants