Skip to content

[BUG] JSQLParser 5.4-SNAPSHOT : ClickHouse : C-style ternary operator (? :) not supported in SELECT #2436

Description

@tomershay

Failing SQL Feature

ClickHouse supports the C-style ternary conditional operator cond ? then : else as an alias for the if(cond, then, else) function. For example, x > 0 ? 'y' : 'n' returns 'y' when x > 0 and 'n' otherwise. JSQLParser fails to parse this operator when used as a select item.

See the ClickHouse docs:
https://clickhouse.com/docs/en/sql-reference/functions/conditional-functions

SQL Example

CREATE TABLE t (x Int32) ENGINE = MergeTree ORDER BY x;

INSERT INTO t VALUES (1);

SELECT x > 0 ? 'y' : 'n' FROM t;

Parsing error

ParseException: Encountered: "?" / "?", at line 1, column 14, in lexical state DEFAULT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions