timeplus-io / proton

A stream processing engine and database, and a fast and lightweight alternative to ksqlDB and Apache Flink, 🚀 powered by ClickHouse
https://timeplus.com
Apache License 2.0
1.58k stars 69 forks source link

Unbalanced parentheses in a session are considered an error #810

Closed KVeschgini closed 3 months ago

KVeschgini commented 3 months ago

Describe what's wrong Unbalanced parentheses in a session are considered an error when definitions are being loaded from the store.

How to reproduce

CREATE STREAM speed (speed float64)
CREATE MATERIALIZED VIEW v AS
SELECT
  window_start AS start, window_end AS end, avg(speed)
FROM
  session(speed, 1m, [speed > 50,speed < 50))
GROUP BY
  window_start, window_end
SHOW CREATE v

Error message and/or stacktrace

Query id: efad8ca0-5950-433c-a871-4367a0ef7680

0 rows in set. Elapsed: 0.001 sec.

Received exception from server (version 1.5.12):
Code: 62. DB::Exception: Received from localhost:8463. DB::Exception: Syntax error (in file /home/kambis/proton-data/store/90f36a1a-9142-4f7c-aac9-42c4c00ebd90/v.sql): failed at position 521 (')') (line 12, col 94): ))
GROUP BY
  window_start, window_end
. Expected end of query. (SYNTAX_ERROR)

This is the content of v.sql

ATTACH MATERIALIZED VIEW _ UUID '4354ad70-167f-4f43-8963-b42ae2e93775' INTO INNER UUID '40909870-702c-4d18-a9db-db6745285516'
(
  `start` datetime64(3, 'UTC'),
  `end` datetime64(3, 'UTC'),
  `avg(speed)` float64,
  `_tp_time` datetime64(3, 'UTC') DEFAULT now64(3, 'UTC') CODEC(DoubleDelta, LZ4),
  INDEX _tp_time_index _tp_time TYPE minmax GRANULARITY 2
) AS
SELECT
  window_start AS start, window_end AS end, avg(speed)
FROM
  session(default.speed, 1m, [speed > 50 AS __tp_session_start,speed < 50 AS __tp_session_end))
GROUP BY
  window_start, window_end

and the corresponding line 12 is

  session(default.speed, 1m, [speed > 50 AS __tp_session_start,speed < 50 AS __tp_session_end))                                                                                                    
                                                                                             ^
                                                                                          col 94
yl-lisen commented 3 months ago

@KVeschgini thanks for the bug report, the issue has been fixed and will be included in the next release