53: TYPE_MISMATCH (code 53)
A value that cannot be converted to the other side's type met a comparison or an IN list.
- 오류 코드
53- 이름
TYPE_MISMATCH
의미
TYPE_MISMATCH (53) is raised when comparison or assignment needs a common type and none exists, for example a string that cannot convert to UInt64. Array(Tuple) against String fails with CANNOT_READ_ARRAY_FROM_TEXT (130) instead. It differs from ILLEGAL_TYPE_OF_ARGUMENT (43), which complains about a function argument.
일반적인 원인
- Comparing a numeric column to a quoted string literal from application code.
- An IN list literal holding a value that cannot convert to the left side's type.
- INSERT data whose columns do not match the declared schema; unparsable values raise 6 (CANNOT_PARSE_TEXT) instead.
Find the cause
`DESCRIBE TABLE` both sides, `system.query_log` for the failed statement, and `toTypeName(expr)` in a SELECT to print any expression's type.
해결 방법
-
Cast explicitly so the intent is on record.
SELECT * FROM events WHERE id = toUInt64('42'); -
Match the IN subquery type to the left column.
SELECT * FROM events WHERE user_id IN (SELECT toUInt64(external_id) FROM mapping);
-
Insert with explicit types rather than relying on inference.
INSERT INTO events (user_id) SELECT toUInt64(col) FROM staging;
Other ways to handle it
toTypeName() is the fastest way to see a type. SELECT ... WHERE toTypeName(col) = 'UInt64' guards generated SQL.
안전하게 재현하세요
SELECT 1 WHERE 1 IN ['a']; raises TYPE_MISMATCH between String and UInt64.
질문
Does ClickHouse ever compare String and numbers implicitly?
It converts when the string parses, so WHERE id = '42' matches a UInt64 column. It raises 53 only when the string cannot be converted, such as 'abc'. Cast explicitly anyway so the intent is on record.
Why does the message mention IN?
IN list literals raise it (1 IN ['a'] gives 53). An IN subquery with a mismatched type does not raise here, and a bad INSERT value raises 6 (CANNOT_PARSE_TEXT) instead.
관련 오류
More tables, columns and metadata errors
코드와 메시지 텍스트의 출처는 다음과 같습니다 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. 라이선스 세부 정보 인용된 오류 메시지 텍스트의 권리는 해당 데이터베이스 공급업체에 있습니다.