Skip to content

Conversation

@kyleconroy
Copy link
Collaborator

Parser changes:

  • SELECT ALL syntax (SELECT ALL 'a')
  • FILTER clause on aggregate functions (argMax() FILTER(WHERE ...))
  • DROP SETTINGS PROFILE (DROP SETTINGS PROFILE IF EXISTS ...)
  • CREATE NAMED COLLECTION (CREATE NAMED COLLECTION ... AS ...)
  • WITH column AS alias syntax (WITH number AS k SELECT k)
  • SHOW TABLES NOT LIKE (SHOW TABLES NOT LIKE '%')
  • SHOW CREATE QUOTA (SHOW CREATE QUOTA default)
  • LIMIT BY with second LIMIT (LIMIT 1 BY * LIMIT 1)
  • WITH TOTALS HAVING clause (SELECT count() WITH TOTALS HAVING x != 0)
  • COLLATE in column definitions (varchar(255) COLLATE binary NOT NULL)
  • SETTINGS with keyword assignments (SETTINGS limit=5)
  • TTL GROUP BY SET clause (TTL d + interval 1 second GROUP BY x SET y = max(y))
  • DROP ROW POLICY ON wildcard (DROP ROW POLICY ... ON default.*)
  • INSERT FROM INFILE COMPRESSION (FROM INFILE '...' COMPRESSION 'gz')
  • FROM before SELECT syntax (FROM numbers(1) SELECT number)
  • Parenthesized SELECT at statement level ((SELECT 1))
  • EXISTS table syntax (EXISTS db.table)
  • DROP TABLE FORMAT (DROP TABLE IF EXISTS t FORMAT Null)

AST changes:

  • Added ExistsQuery type for EXISTS table_name statements

Reduced parser errors from 53 to 28 (47% reduction)

Parser changes:
- SELECT ALL syntax (SELECT ALL 'a')
- FILTER clause on aggregate functions (argMax() FILTER(WHERE ...))
- DROP SETTINGS PROFILE (DROP SETTINGS PROFILE IF EXISTS ...)
- CREATE NAMED COLLECTION (CREATE NAMED COLLECTION ... AS ...)
- WITH column AS alias syntax (WITH number AS k SELECT k)
- SHOW TABLES NOT LIKE (SHOW TABLES NOT LIKE '%')
- SHOW CREATE QUOTA (SHOW CREATE QUOTA default)
- LIMIT BY with second LIMIT (LIMIT 1 BY * LIMIT 1)
- WITH TOTALS HAVING clause (SELECT count() WITH TOTALS HAVING x != 0)
- COLLATE in column definitions (varchar(255) COLLATE binary NOT NULL)
- SETTINGS with keyword assignments (SETTINGS limit=5)
- TTL GROUP BY SET clause (TTL d + interval 1 second GROUP BY x SET y = max(y))
- DROP ROW POLICY ON wildcard (DROP ROW POLICY ... ON default.*)
- INSERT FROM INFILE COMPRESSION (FROM INFILE '...' COMPRESSION 'gz')
- FROM before SELECT syntax (FROM numbers(1) SELECT number)
- Parenthesized SELECT at statement level ((SELECT 1))
- EXISTS table syntax (EXISTS db.table)
- DROP TABLE FORMAT (DROP TABLE IF EXISTS t FORMAT Null)

AST changes:
- Added ExistsQuery type for EXISTS table_name statements

Reduced parser errors from 53 to 28 (47% reduction)
- Added parse_error field to testMetadata struct
- When parse_error is true, tests skip gracefully if parsing fails
  (these are tests for SQL that ClickHouse itself expects to fail)
- Marked 59 tests with clientError SYNTAX_ERROR as parse_error: true
- Reduces reported parser errors from 28 to 20

The parse_error flag is used for queries that have -- { clientError SYNTAX_ERROR }
comments, indicating they are intentionally invalid SQL per ClickHouse's own test suite.
Lexer improvements:
- Add dollar-quoted string support ($$...$$)
- Add hex P notation float support (0x123p4)
- Fix backtick escaping (ta``ble -> ta`ble)
- Skip BOM (byte order mark) characters
- Allow $ in identifier names ($alias$name$)

Parser improvements:
- SYSTEM DROP FORMAT SCHEMA CACHE support
- EXPLAIN AST options (optimize=0, etc.)
- WITH scalar expression without alias (WITH 1 SELECT 1)
- DROP USER with @ hostname (user@localhost)
- KEY keyword as implicit alias in expressions
- Complex UNION with parentheses in FROM clause

Test results: 6066 passing, 758 skipped, 0 failing
Down from 20 parser errors to 7 remaining.
…ovements

- Add CARET (^) handling in qualified identifiers for JSON path notation
- Support parenthesized ALTER mutations: (DELETE WHERE ...), (UPDATE ...)
- Add DELETE WHERE and UPDATE mutations to ALTER TABLE parsing
- Support MODIFY SETTING (singular) in addition to SETTINGS
- Fix CONSTRAINT CHECK parsing in CREATE TABLE
- Allow keywords as CTE aliases (VALUES, KEY, etc.)
- Fix SETTINGS value parsing to stop before AS (for CTAS)
- Add TTL WHERE clause support for conditional deletion
- Fix TTL GROUP BY with multiple expressions and SET clause

Parser errors reduced from 19 to 4.
Add support for ClickHouse's PARALLEL WITH syntax for dropping multiple
tables in parallel:
  DROP TABLE IF EXISTS t1 PARALLEL WITH DROP TABLE IF EXISTS t2

Parser errors now reduced from 19 to 3 (84% reduction).
- Skip inline data after FORMAT clause (e.g., FORMAT JSONEachRow {...})
- Support parentheses-optional * EXCEPT syntax (e.g., * EXCEPT col)
- Support named window reference in parentheses: OVER (w0)

All 19 parser errors are now fixed (100% reduction).
@kyleconroy kyleconroy merged commit 47bf571 into main Dec 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants