Open murfel opened 1 year ago
Analyze in which cases parentheses are hilited, find a semantical meaning behind the hilite (there could be none, or it could be inconsistent), see if the user understands that semantic and if it does help to understand the query.
clickhouse format --hilite --query "CREATE DICTIONARY somename (Name ClickHouseDataType DEFAULT '' EXPRESSION rand64()) SOURCE(HTTP(url 'http://[::1]/os.tsv' format 'TabSeparated' credentials(user 'user' password 'password') headers(header(name 'API-KEY' value 'key'))))"
The parentheses of CREATE DICTIONARY
, SOURCE
, and HTTP
are not hilited. However, the parentheses within HTTP
being FunctionWithKeyValueArguments
consisting of ASTPair
s are hilited.
The parentheses are hilited, though I'm not sure what's the semantical meaning behind this.
CREATE TABLE t AS (SELECT 1) COMMENT 'hello'
CREATE INDEX idx_table_name ON table_name((column1, column2)) TYPE Int8 GRANULARITY 1
Incorrect query
clickhouse-format --query "SELECT 1 SETTINGS additional_table_filters={'table': '1'}";
SELECT 1
SETTINGS additional_table_filters = [('table', '1')]
❯ clickhouse-local -mn
ClickHouse local version 23.3.1.1881.
LAPTOP-. :) SELECT 1
SETTINGS additional_table_filters = [('table', '1')];
Syntax error: failed at position 46 ('[') (line 2, col 37):
SELECT 1
SETTINGS additional_table_filters = [('table', '1')];
Expected one of: DEFAULT, TRUE, FALSE, function, compound identifier, list of elements, identifier, literal or map, literal, NULL, number, Bool, true, false, string literal, token, OpeningCurlyBrace
It seems a bit strange that the database and table are hilited as keywords, instead of identifiers:
And here not hilited at all:
Creating an umbrella ticket to collect all correct but somewhat inconsistent or inconvenient behaviours of
clickhouse-format
, whether it's hiliting, line breaks, or excessive parenthesis.Issues from here could be used as a good first issue or intern tasks (linking in #42194) for those with a passion for UX and AST visitors.