You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Numeric literals and column names which solely consist of digits are not correctly distinguished under a certain circumstance #35608
Numeric literals and column names which solely consist of digits are
not correctly distinguished under a certain circumstance, and can
yield a type error.
Does it reproduce on recent release?
21.12.2.1 and 22.2.3.1 are known to have this issue.
How to reproduce
Queries like this result in an error:
CREATETABLEtestdata (`1` String) ENGINE=MergeTree ORDER BY tuple();
INSERT INTO testdata VALUES ('testdata');
SELECT*FROM (
SELECT if(isValidUTF8(`1`), NULL, 'error!') AS error_message,
if(error_message IS NULL, 1, 0) AS valid
FROM testdata
)
WHERE valid
;
Received exception from server (version 21.12.2):
Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Illegal type UInt8 of argument of function isValidUTF8: While processing SELECT if(isValidUTF8(`1`), NULL, 'error!') AS error_message, if(error_message IS NULL, 1, 0) AS valid FROM testdata WHERE valid. (ILLEGAL_TYPE_OF_ARGUMENT)
This works:
SELECT if(isValidUTF8(`1`), NULL, 'error!') AS error_message,
if(error_message IS NULL, 1, 0) AS valid
FROM testdata
;
This works too:
SELECT*FROM (
SELECT if(isValidUTF8(`1`), NULL, 'error!') AS error_message,
if(error_message IS NULL, 2, 0) AS valid -- Literal 2 as opposed to 1.FROM testdata
)
WHERE valid
;
It seems the parser fails to interpret column names that look like
integers when they are in nested queries.
:) select 'str', 1 as `'str'`
Code: 352. DB::Exception: Received from localhost:9000. DB::Exception: Block structure mismatch in (columns with identical name must have identical structure) stream: different types:
'str' String Const(size = 0, String(size = 1))
'str' UInt8 Const(size = 0, UInt8(size = 1)). (AMBIGUOUS_COLUMN_NAME)
Activity
Avogar commentedon Mar 25, 2022
Avogar commentedon Mar 25, 2022
Avogar commentedon Mar 25, 2022
@kitaisreal is working on refactoring and improvements in identifier and alias analysis in #31796 and maybe his work will fix it
Close: #35608