Is it possible to have an SQL reference with syntax diagrams? #33158
-
Since the substitions for table and database names feature is introduced in v21.12 release, I've been thinking that if the SQL syntax of ClickHouse has a formal grammar that can be expressed with WSN or not. If it is, can we have a syntax diagram like this: Which looks much better than this: [WITH expr_list|(subquery)]
SELECT [DISTINCT [ON (column1, column2, ...)]] expr_list
[FROM [db.]table | (subquery) | table_function] [FINAL]
[SAMPLE sample_coeff]
[ARRAY JOIN ...]
[GLOBAL] [ANY|ALL|ASOF] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER|SEMI|ANTI] JOIN (subquery)|table (ON <expr_list>)|(USING <column_list>)
[PREWHERE expr]
[WHERE expr]
[GROUP BY expr_list] [WITH ROLLUP|WITH CUBE] [WITH TOTALS]
[HAVING expr]
[ORDER BY expr_list] [WITH FILL] [FROM expr] [TO expr] [STEP expr]
[LIMIT [offset_value, ]n BY columns]
[LIMIT [n, ]m] [WITH TIES]
[SETTINGS ...]
[UNION ...]
[INTO OUTFILE filename [COMPRESSION type] ]
[FORMAT format] A better example would be the following IBM product ducumentation page which even lets users to click on expressions to see their production rules and relevant documentation in the same page. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Currently no. Unfortunately our parser is not declarative and we cannot transform it to this graph. You can find incomplete, unsupported ANTLR grammar definition for ClickHouse here: It covers maybe 80% of the language. |
Beta Was this translation helpful? Give feedback.
Currently no. Unfortunately our parser is not declarative and we cannot transform it to this graph.
I want to address this problem by rewriting it. Previous attempt with ANTLR was unsuccessful.
You can find incomplete, unsupported ANTLR grammar definition for ClickHouse here:
https://github.com/ClickHouse/ClickHouse/tree/master/utils/antlr
It covers maybe 80% of the language.