Skip to content

Parse new ClickHouse 26.x syntax (batch 1) - #127

Open
kyleconroy wants to merge 12 commits into
claude/project-thread-8e2oya-sync-testsfrom
claude/project-thread-8e2oya-syntax-1
Open

kyleconroy wants to merge 12 commits into
claude/project-thread-8e2oya-sync-testsfrom
claude/project-thread-8e2oya-syntax-1

Conversation

@kyleconroy

Copy link
Copy Markdown
Collaborator

Requested by Kyle · project thread

Stacked on #126 (test sync). Its base will move to main as the stack merges.

Summary

First batch of parser and explain fixes for syntax that ClickHouse added between 25.8 and 26.8. It takes explain_todo from 3,649 to 2,900 statements. One commit per feature:

  • WITH name AS MATERIALIZED (...) CTEs
  • CREATE TABLE ... EMPTY AS SELECT
  • SOME (subquery), and the 26.8 explain output for ANY/ALL subqueries
  • JSON dynamic path access json.@path
  • ALTER TABLE ... REWRITE PARTS, APPLY PATCHES/APPLY DELETED MASK IN PARTITION
  • All EXTRACT units and date_part('unit', expr)
  • IN PARTITION ID for every ALTER command (shared helper in parser and explain)
  • Column alias lists: WITH t (a, b) AS (...) and FROM (...) t(a, b)
  • SYSTEM RELOAD DICTIONARY 'quoted name'
  • LIKE ... ESCAPE 'c', view COMMENT after the SELECT, and COMMENT printed before the SELECT as 26.8 does
  • Column modifiers (CODEC, STATISTICS, TTL, COMMENT, SETTINGS, ...) in any order, printed in ClickHouse's child order

No golden explain*.txt file was edited.

Test Plan

  • Each change was compared against EXPLAIN AST from a local ClickHouse 26.8.51.4 server.
  • go test ./parser/... -check-explain removed the newly passing statements from explain_todo.
  • go test ./... passes.

Generated by Claude Code

claude added 11 commits December 1, 2026 04:55
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
ClickHouse 26 no longer repeats the select list and table of the
rewritten subquery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
Accept every interval kind alias and the PostgreSQL-compatible units
(EPOCH, DOW, DOY, ISODOW, ISOYEAR, CENTURY, DECADE, MILLENNIUM,
TIMEZONE_HOUR, TIMEZONE_MINUTE) in EXTRACT(unit FROM expr), and explain
date_part('unit', expr) the same way. EXTRACT(WEEK ...) is toISOWeek.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
Supports WITH t (a, b) AS (SELECT ...) and FROM (...) t(a, b).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
- LIKE/ILIKE take an optional ESCAPE 'c' third argument.
- COMMENT is printed before the SELECT for views and CREATE ... AS SELECT,
  matching ClickHouse 26.8, and may follow the SELECT of a view.
- comment can be used as an implicit column alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
CODEC, STATISTICS, TTL, COLLATE, PRIMARY KEY, COMMENT and SETTINGS may
appear in any order after a column's default. EXPLAIN prints them as
type, default, comment, codec, settings, statistics, TTL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KB7DMX365Nmn5ksnY
@kyleconroy kyleconroy self-assigned this Dec 1, 2026
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.

2 participants