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
[BUG] JSQLParser 5.4-SNAPSHOT : ClickHouse : Parametric type Nullable(Decimal(p, s)) not supported as CAST target #2441
ClickHouse supports parametric (constructor-style) data types as the target of a CAST, including nested ones such as Nullable(Decimal(10, 2)). Here Decimal(10, 2) declares a decimal with precision 10 and scale 2, and Nullable(...) wraps it so the column can also hold NULL. JSQLParser fails to parse this type expression when it is used as the target type of a CAST(... AS ...).
CREATE TABLE cast_demo (id UInt32, x Float64) ENGINE = MergeTree ORDER BY id;
INSERT INTO cast_demo (id, x) VALUES (1, 10.5), (2, 3.14159), (3, 1234567.891), (4, 0);
SELECT CAST(x AS Nullable(Decimal(10, 2))) FROM cast_demo;
Parsing Error
ParseException: Encountered: <OPENING_BRACKET> / "(", at line 3, column 25, in lexical state DEFAULT.
Was expecting one of these terminals within expansion starting at 9127:5:
<K_FORMAT> (inside 9125:5) ...
<CLOSING_BRACKET> (inside 9127:5)
Thanks for the report. The root cause is that the argument production of ColDataType only accepted atomic tokens (numbers, string literals, bare identifiers/keywords), so a nested parametric type such as Decimal(10, 2) inside Nullable(...) was rejected at its inner (.
Opened #2451 to allow an argument that is itself a parametric type (DATA_TYPE or identifier immediately followed by an argument list) to be parsed as a nested ColDataType. SELECT CAST(x AS Nullable(Decimal(10, 2))) FROM cast_demo and LowCardinality(Decimal(10, 2)) now parse and round-trip; the full test suite (4647 tests) passes with no regressions.
Activity
fudianchn commentedon Aug 7, 2026
Thanks for the report. The root cause is that the argument production of
ColDataTypeonly accepted atomic tokens (numbers, string literals, bare identifiers/keywords), so a nested parametric type such asDecimal(10, 2)insideNullable(...)was rejected at its inner(.Opened #2451 to allow an argument that is itself a parametric type (
DATA_TYPEor identifier immediately followed by an argument list) to be parsed as a nestedColDataType.SELECT CAST(x AS Nullable(Decimal(10, 2))) FROM cast_demoandLowCardinality(Decimal(10, 2))now parse and round-trip; the full test suite (4647 tests) passes with no regressions.fix: support nested parametric data types as CAST target (JSQLParser#…