Skip to content

Got "Unknown identifier" while quering #27068

Closed

Description

@assassinors

Describe the bug
Hello,recently I met a bug while using clickhouse to do some queries with tableau server,which is weird and I can not find any solutions after searching the internet.

How to reproduce
Here are the steps to reproduce the bug.

  1. ClickHouse Server version : 21.1.2.15

  2. Table DDL
    CREATE TABLE test ( id String, create_time DateTime ) ENGINE = MergeTree ORDER BY id

  3. insert some values into the table
    insert into test values(1,'1970-02-01 00:00:00');
    insert into test values(2,'1970-02-01 00:00:00');

  4. the query sql
    select id,'1997-02-01' as create_time from test where test.create_time='1970-02-01 00:00:00'
    once you run the sql,you'll get an exception which is said "Unkown identifier create_time there are columns : id: while processing create_time='1997-02-01 00:00:00'(version 21.1.2.15 (official build))"
    I also try these steps in mysql,however,there is no problem in it. So,I think it is a bug in clickhouse.

I know it's kind of strange that the column alias is the same as the column in the table,but it is tableau's behaviour and I can hardly change it.

Activity

  1. added
    bug
    on Aug 2, 2021
  2. self-assigned this
    on Aug 2, 2021
  3. kitaisreal commented on Aug 2, 2021

    @kitaisreal
    Contributor

    It is related to identifier resolving. We have task that will fix that #23194.
    As workaround you can specify different alias_name if possible.

    select id, '1997-02-01' as create_time_test from test where test.create_time='1970-02-01 00:00:00'
  4. 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