Skip to content

Ambiguous column error reported when fully qualifying columns from a table that appears multiple times in the FROM clause #61014

Closed

Description

@lukaseder

Describe what's wrong

When repeating the same table multiple times in the FROM clause (with and without alias), then fully qualified columns are reported as ambiguous, when they really aren't.

Does it reproduce on the most recent release?

Yes

How to reproduce

  • Which ClickHouse server version to use: 24.2.1.2248
  • Which interface to use, if it matters: JDBC (but it doesn't matter)
  • Non-default settings, if any: N/A
create table a (i int) engine = Log();

select 
  default.a.i
from 
  default.a,
  default.a as x;

Expected behavior

The query should work

Error message and/or stacktrace

Received exception from server (version 24.2.1):
Code: 352. DB::Exception: Received from localhost:9000. DB::Exception: Ambiguous column 'default.a.i': While processing default.a.i. (AMBIGUOUS_COLUMN_NAME)
(query: select
default.a.i
from
default.a,
default.a as x;)

Workaround

Omit full qualification:

create table a (i int) engine = Log();

select 
  a.i
from 
  default.a,
  default.a as x;

Activity

  1. added
    potential bug
    on Mar 7, 2024
  2. added
    bug
    and removed
    potential bug
    on Mar 14, 2024
  3. lukaseder commented on Apr 2, 2024

    @lukaseder
    Author

    This no longer reproduces with 24.3.1.2672

  4. den-crane commented on Apr 2, 2024

    @den-crane
    Contributor

    New analyzer is enabled by default with 24.3.

  5. lukaseder commented on Apr 2, 2024

    @lukaseder
    Author

    Good to know, thanks

  6. added a commit that references this issue on Apr 3, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions