Skip to content

Column alias problem - name conflict #14978

Closed

Description

@bgranvea

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

Activity

  1. added
    bug
    on Sep 18, 2020
  2. added
    comp-joins
    on Sep 18, 2020
  3. filimonov commented on Oct 12, 2020

    @filimonov
    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

  4. added a commit that references this issue on Apr 17, 2021
  5. added 3 commits that reference this issue on Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcomp-joins

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions