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

Column alias problem - name conflict #14978

Closed
bgranvea opened this issue Sep 18, 2020 · 1 comment · Fixed by #62185
Closed

Column alias problem - name conflict #14978

bgranvea opened this issue Sep 18, 2020 · 1 comment · Fixed by #62185
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

@bgranvea
Copy link
Contributor

How to reproduce

# clickhouse-client
ClickHouse client version 20.5.4.40 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 20.5.4 revision 54435.

> create table test1(insid UInt64, insidvalue UInt64) ENGINE=MergeTree ORDER BY tuple();     
> create table test2(insid UInt64, svalue String) ENGINE=MergeTree ORDER BY tuple();     

> SELECT NULL AS svalue FROM test1 t1 LEFT JOIN (SELECT insid,svalue FROM test2) t2 ON t1.insid=t2.insid WHERE t2.svalue='test'

Code: 47. DB::Exception: Received from localhost:9000. DB::Exception: Unknown identifier: svalue there are columns: insid.

Workaround: change column alias in select to avoid name conflict:

> SELECT NULL AS _svalue FROM test1 t1 LEFT JOIN (SELECT insid,svalue FROM test2) t2 ON t1.insid=t2.insid WHERE t2.svalue='test'
=> ok
@bgranvea bgranvea added the bug Confirmed user-visible misbehaviour in official release label Sep 18, 2020
@filimonov
Copy link
Contributor

CREATE TABLE test1
(
    `insid` UInt64,
    `insidvalue` UInt64
)
ENGINE = MergeTree
ORDER BY tuple();

CREATE TABLE test2
(
    `insid` UInt64,
    `svalue` String
)
ENGINE = MergeTree
ORDER BY tuple();

SELECT NULL AS svalue
FROM test1 AS t1
LEFT JOIN 
(
    SELECT 
        insid,
        svalue
    FROM test2
) AS t2 ON t1.insid = t2.insid
WHERE t2.svalue = 'test';

Regression. Was working on <= 19.1

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