Skip to content

Use of explicit table.column alongside alias for the same column fails for function calls #39923

Closed

Description

@niteshpdt

Describe what's wrong

I'd like to alias a column to have the same name as an existing column but also make use of the original column.

The following works as expected:

SELECT
    errors.name AS labels,
    value,
    'ch_errors_total' AS name
FROM system.errors
LIMIT 5

Query id: 187cd40f-71ec-43ed-b59b-1c4fc8c4be34

┌─labels─────────────┬─value─┬─name────────────┐
│ BAD_ARGUMENTS      │    20 │ ch_errors_total │
│ UNKNOWN_IDENTIFIER │    22 │ ch_errors_total │
│ UNKNOWN_FORMAT     │     4 │ ch_errors_total │
│ CYCLIC_ALIASES     │     1 │ ch_errors_total │
└────────────────────┴───────┴─────────────────┘

4 rows in set. Elapsed: 0.001 sec. 

The following however, does not work:

SELECT
    map('name', errors.name) AS labels,
    value,
    'ch_errors_total' AS name
FROM system.errors
LIMIT 5

Query id: 4cb16e3f-6610-49b3-a175-936998be94d5


0 rows in set. Elapsed: 0.001 sec. 

Received exception:
Code: 47. DB::Exception: Unknown identifier: name; there are columns: value, 'name': While processing map('name', name) AS labels, value, 'ch_errors_total' AS name. (UNKNOWN_IDENTIFIER)

Does it reproduce on recent release?
Yes, we're on the latest release 22.7

Activity

  1. added
    potential bug
    on Aug 5, 2022
  2. self-assigned this
    on Aug 5, 2022
  3. kitaisreal commented on Aug 5, 2022

    @kitaisreal
    Contributor

    Related to #23194.

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

    potential bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions