Support COMMENT before AS SELECT in CREATE MATERIALIZED VIEW#262
Conversation
ClickHouse 26.2+ changed SHOW CREATE TABLE output to place COMMENT before AS SELECT, while 25.x places it after. The parser only supported COMMENT after AS SELECT, causing parse failures on 26.2+. Now tries COMMENT in both positions: - Before AS SELECT (ClickHouse 26.2+ SHOW CREATE TABLE format) - After AS SELECT (ClickHouse 25.x SHOW CREATE TABLE format) Fixes AfterShip#261
365c90f to
71bc41d
Compare
💡 Codex Reviewclickhouse-sql-parser/parser/parser_table.go Lines 671 to 675 in 365c90f When building ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…26.2+ format) Adds test SQL file and golden output/format/beautify files for CREATE MATERIALIZED VIEW with COMMENT between column list and AS SELECT, which is the format ClickHouse 26.2+ uses in SHOW CREATE TABLE output.
|
@sharadgaur Thanks for your improvement. |
Summary
ClickHouse's
SHOW CREATE TABLEoutputsCOMMENTbetween the column list andAS SELECTfor materialized views, but the parser only supportedCOMMENTafterAS SELECT.Before (fails)
After (works)
Both positions are now supported:
COMMENTbeforeAS SELECT(SHOW CREATE TABLE format) ✅COMMENTafterAS SELECT(documented syntax) ✅COMMENT✅Change
Move the
tryParseComment()call before theAS SELECTparsing, with a fallback to also try afterAS SELECTif no comment was found before.All existing tests pass.
Fixes #261