ClickHouse supports the COLUMNS() expression with APPLY, which applies a function or lambda expression to all columns matching a regular expression. JSQLParser fails to parse the lambda expression used by APPLY.
See the ClickHouse docs:
https://clickhouse.com/docs/sql-reference/statements/select
SQL Example
CREATE TABLE metrics
(
id UInt32,
metric_cpu Float64,
metric_memory Float64,
metric_disk Float64,
hostname String
)
ENGINE = MergeTree
ORDER BY id;
INSERT INTO metrics
(id, metric_cpu, metric_memory, metric_disk, hostname)
VALUES
(1, 12.34567, 78.90123, 45.67891, 'server-1'),
(2, 98.76543, 23.45678, 67.89012, 'server-2'),
(3, 55.55555, 44.44444, 88.88888, 'server-3');
SELECT
COLUMNS('^metric_')
APPLY(x -> round(x, 2))
FROM metrics;
The query executes successfully in ClickHouse and returns the matching metric_* columns with round(x, 2) applied to each column.
Parsing error
ParseException: Encountered: "->" / "->", at line 3, column 13, in lexical state DEFAULT.
Was expecting one of these terminals within expansion starting at 6349:13:
<K_COMMA> (inside 6348:17) ...
<CLOSING_BRACKET> (inside 6349:13) ...
The failure appears to be caused by JSQLParser not accepting the ClickHouse lambda expression syntax:
x -> round(x, 2)
inside COLUMNS(...) APPLY(...).
Tested with ClickHouse 26.8.
ClickHouse supports the
COLUMNS()expression withAPPLY, which applies a function or lambda expression to all columns matching a regular expression. JSQLParser fails to parse the lambda expression used byAPPLY.See the ClickHouse docs:
https://clickhouse.com/docs/sql-reference/statements/select
SQL Example
The query executes successfully in ClickHouse and returns the matching metric_* columns with round(x, 2) applied to each column.
Parsing error
The failure appears to be caused by JSQLParser not accepting the ClickHouse lambda expression syntax:
x -> round(x, 2)inside COLUMNS(...) APPLY(...).
Tested with ClickHouse 26.8.