// ClickHouse error reference

47: UNKNOWN_IDENTIFIER (code 47)

A column or alias in SELECT, WHERE or ORDER BY does not exist in the tables the query sees.

오류 코드
47
이름
UNKNOWN_IDENTIFIER
카테고리
Syntax and parsing
오류 메시지
Unknown expression identifier `{identifier}`. In scope {query}.

의미

UNKNOWN_IDENTIFIER (47) is raised during analysis when a name cannot be resolved to any column, alias or CTE. The SQL parsed fine (that would be 62); the names do not line up. It is the ClickHouse twin of no such column.

일반적인 원인

  • A misspelled or differently cased column name.
  • The column exists on a different table than the one the query reads.
  • An alias is referenced outside the clause that defines it, or an upstream schema change renamed the column.

Find the cause

`system.columns` for what actually exists, `SHOW CREATE TABLE` for views that embed column lists, `system.query_log` for the failed query.

해결 방법

  1. Check the real column names and their case.

    SELECT name FROM system.columns WHERE database = 'my_db' AND table = 'my_table';
  2. Qualify the column with the table name. An unqualified column that exists in both joined tables did not raise code 47 on 26.9.3.38; it resolved to the left table.

    SELECT o.id FROM orders o JOIN users u ON o.user_id = u.id;
  3. When a materialized view depends on a renamed column, add the new column to the view's target table first, then change its SELECT. MODIFY QUERY fails with code 16 (NO_SUCH_COLUMN_IN_TABLE) when the target lacks the column. A view with an implicit target was not tested here.

    ALTER TABLE my_mv MODIFY QUERY SELECT id, new_name FROM my_table;

Other ways to handle it

EXISTS 그리고 system.columns checks help generated SQL. DESCRIBE TABLE shows a table's columns fast.

안전하게 재현하세요

CREATE TABLE scratch_c (id UInt32) ENGINE = MergeTree ORDER BY id; then run SELECT nope FROM scratch_c to get code 47.

질문

Is this the same as SYNTAX_ERROR?

No. 62 means the token stream could not parse. 47 means it parsed and a name did not resolve.

Why do aliases in WHERE fail sometimes?

In ClickHouse 26.9 an alias from the same SELECT resolves in WHERE, in PREWHERE and inside aggregate arguments. Aggregate functions are still not allowed in WHERE; that fails with code 184 ILLEGAL_AGGREGATION.

관련 오류

코드와 메시지 텍스트의 출처는 다음과 같습니다 ClickHouse documentation (system.errors). 전체 목록은 ClickHouse error list 또는 모든 데이터베이스 오류 검색.

// 오류는 줄이고, 수정은 빠르게

Work on ClickHouse in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for ClickHouse and the other databases you use.

이 페이지의 텍스트와 데이터: CC BY 4.0, 출처: SQLly (sqlly.app). 코드와 SQL 스니펫: MIT. 라이선스 세부 정보 인용된 오류 메시지 텍스트의 권리는 해당 데이터베이스 공급업체에 있습니다.