ClickHouse: clickhouse-format doesn't hilite some identifiers
Hey!
- In this query the
identifier
is not hilited — is it intended behaviour? I think it should either be hilited as an identifier, or an alias.
$ ./clickhouse-format --hilite --query "with identifier as (select * from table) select * from table"
WITH identifier AS
(
SELECT *
FROM table
)
https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTWithElement.cpp#L21
-
And also there’s another identifier output without being hilited, but I cannot come up with the query which corresponds to this code - any help? https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTWithAlias.cpp#L23
-
There seems to be an inconsistensy of manually applied hilite, as it’s never removed within this if: https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTFunction.cpp#L585
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 34 (34 by maintainers)
ADD INDEX prints
index_decl
, DROP INDEX printsindex
, it looks more like a decision rather than an inconsistency. Moreover, my refactoring doesn’t automatically change this behaviour, so I’m keeping this as is.https://github.com/ClickHouse/ClickHouse/blob/bbf94a2664be9b5ba3bdc5f10ccde150cae08f34/src/Parsers/ASTAlterQuery.cpp#L220
UPD It’s even consistent with something like
CREATE TABLE name
, which wouldn’t be hilitingname
as identifier. The reasoning behind this could be: it’s an identifier-to-be, so let’s not hilite it just yep.The one with SOURCE is listed above. I’ll investigate if there are overlapping bugs.
Thank you!
clickhouse format --hilite --query "alter table tab add index index_name a + b type set GRANULARITY 1"
clickhouse format --hilite --query "alter table tab drop index index_name"
@murfel I see it can be either
TEST
,SYNC
, orASYNC
.Do we need space between
TESTSYNC
orTESTASYNC
? https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTKillQueryQuery.cpp#L40Hilite not taken off https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTKillQueryQuery.cpp#L31
UPD
Matching parenthesis is not hilited https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTDictionary.cpp#L164
UPD
No parenthesis should be hilited in the first place.
Hilite not taken off x4 (4 cases) https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTDictionaryAttributeDeclaration.cpp#L59
UPD Oh boy does this query mess with your terminal!
The hilite hasn’t been taken off, thus the terminal remains hilited as a keyword.
This closing bracket should be hilited, just like its pairing opening bracket https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTCreateQuery.cpp#L436
UPD
Couldn’t find a query to contain both a select and a comment.
I checked documentation for creating table, database, and view here https://clickhouse.com/docs/en/sql-reference/statements/create/
UPD 2 See Nicolai Kochetov’s query below.
Does these really need hilite before the internal thing is written? https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTColumnsMatcher.cpp#L49 https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTColumnsMatcher.cpp#L124 https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTColumnsMatcher.cpp#L202 https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTColumnsMatcher.cpp#L248
https://github.com/ClickHouse/ClickHouse/blob/master/src/Parsers/ASTCreateIndexQuery.cpp#L39 Not visible, if index_name is always hilited as identifier
Thanks! I will hilite the second
b
as an identifier, then.