GeezerVison is showing github.com — [BUG] JSQLParser 5.4-SNAPSHOT : ClickHouse : Parametric type Nullable(Decimal(p, s)) not supported as CAST target · Issue #2441 · JSQLParser/JSqlParser
[BUG] JSQLParser 5.4-SNAPSHOT : ClickHouse : Parametric type Nullable(Decimal(p, s)) not supported as CAST target #2441DescriptionFailing SQL Feature
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 ...).
See the ClickHouse docs:
Full SQL Example
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)
Tested with ClickHouse version: 25.8 Activityfudianchn commented on Aug 7, 2026 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. added a commit that references this issue on Aug 7, 2026This issue will close once commit 3997ba4 is merged into the 'master' branch.3997ba4
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|