Repository navigation
Closed
Labels
bugConfirmed user-visible misbehaviour in official releasecomp-joinsJOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla...minorPriority: minor
Description
How to reproduce
Clickhouse 21.4
EXPLAIN SYNTAX
WITH tbl AS
(
SELECT intDiv(number, 10) AS key_1
FROM numbers(1000)
)
SELECT count()
FROM tbl AS x
INNER JOIN tbl AS z ON x.key_1 = z.key_1
FORMAT TSVRaw
Query id: 5582fbcf-2134-4dc7-89e8-d37e9ae3b060
WITH tbl AS
(
SELECT intDiv(number, 10) AS key_1
FROM numbers(1000)
)
SELECT count()
FROM tbl AS x
ALL INNER JOIN tbl AS z ON key_1 = z.key_1
WITH tbl AS
(
SELECT intDiv(number, 10) AS key_1
FROM numbers(1000)
)
SELECT count()
FROM tbl AS x
ALL INNER JOIN tbl AS z ON key_1 = z.key_1
Query id: b09e46b8-bf78-4882-903a-04150bf85821
0 rows in set. Elapsed: 0.002 sec.
Received exception from server (version 21.4.1):
Code: 352. DB::Exception: Received from localhost:9000. DB::Exception: Column 'key_1' is ambiguous: While processing key_1 = z.key_1.
EXPLAIN SYNTAX
WITH tbl AS
(
SELECT intDiv(number, 10) AS key_1
FROM numbers(1000)
)
SELECT count()
FROM tbl AS x
CROSS JOIN tbl AS z
WHERE x.key_1 = z.key_1
FORMAT TSVRaw
Query id: 4e196c98-54f3-40d4-ae8c-11e5f0800031
WITH tbl AS
(
SELECT intDiv(number, 10) AS key_1
FROM numbers(1000)
)
SELECT count()
FROM tbl AS x
ALL INNER JOIN tbl AS z ON key_1 = z.key_1
WHERE key_1 = z.key_1
WITH tbl AS
(
SELECT intDiv(number, 10) AS key_1
FROM numbers(1000)
)
SELECT count()
FROM tbl AS x
ALL INNER JOIN tbl AS z ON key_1 = z.key_1
WHERE key_1 = z.key_1
Query id: 9b50bb1d-9b4e-4508-8401-2498caf2b051
0 rows in set. Elapsed: 0.004 sec.
Received exception from server (version 21.4.1):
Code: 352. DB::Exception: Received from localhost:9000. DB::Exception: Ambiguous column 'key_1': While processing WITH tbl AS (SELECT intDiv(number, 10) AS key_1 FROM numbers(1000)) SELECT count() FROM tbl AS x ALL INNER JOIN tbl AS z ON key_1 = z.key_1 WHERE key_1 = z.key_1.
Metadata
Metadata
Assignees
Labels
bugConfirmed user-visible misbehaviour in official releasecomp-joinsJOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla...minorPriority: minor
Activity
amosbird commentedon Mar 11, 2021
Could you try constructing a case with this PR #21414 ? It doesn't suffer from this issue by removing useless WITH elements...
UnamedRus commentedon Mar 11, 2021
I can, but that issue not about WITH element's it's more about JOIN rewriting. it would reproduce even without with clause.
amosbird commentedon Mar 11, 2021
Ok. I fail to reproduce with the above queries. Not sure why it's related to explain only.
UnamedRus commentedon Mar 11, 2021
@amosbird
I tried to run queries with that branch, but it completely removing WITH clause which is actually useful in that query :).
However problem is still here, clickhouse removing alias for left table in join, and query from explain syntax doesn't work.
Close: #21584