Skip to content

[BUG] JSQLParser 5.4-SNAPSHOT : ClickHouse : Parametric type Nullable(Decimal(p, s)) not supported as CAST target #2441

Description

@tomershay

Failing 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions