ydb-platform / ydb

YDB is an open source Distributed SQL Database that combines high availability and scalability with strong consistency and ACID transactions
https://ydb.tech
Apache License 2.0
4.02k stars 587 forks source link

Syntax highlighting in YDB CLI in interactive mode #9227

Open vityaman opened 2 months ago

vityaman commented 2 months ago

We "could-have" YQL syntax highlighting in YDB CLI in interactive mode with color schema like we have in Embedded UI Monaco editor. This can be done using YQL ANTLR4 grammar.

After this feature we want to add

vityaman commented 2 months ago

Merged the MR Add YQL syntax highlighting to YDB CLI #7448.

vityaman commented 2 months ago

We noticed, that current implementation is not so good, as it does not distinguish ANSI or extended SQL syntax types and parses text as extended SQL, so ANSI query can be highlighted incorrectly.

We should add an abstraction and support both SQL dialects.

Maybe we should use yql/sql/sql.h interface.

vityaman commented 2 months ago

We noticed, that current solution highlight some identifiers incorrectly as in the YQL keywords can be identifiers.

Examples

select 1 as window;
select group from (SELECT 1 as group);

select group from (select 1 as group) (group = column)
select min(x) from T group by y; (group = keyword)