Repository navigation
Allow COMMENT, CODEC and TTL in any order - #337
Merged
git-hulk merged 1 commit intoOct 28, 2026
Merged
Conversation
git-hulk
approved these changes
Oct 28, 2026
git-hulk
added a commit
to git-hulk/clickhouse-sql-parser
that referenced
this pull request
Oct 28, 2026
ALTER TABLE ... MODIFY COLUMN can reject valid modifier-only changes or store a modifier as the column type. Modifier keywords are treated as type names when the declaration omits its data type. For example, CODEC(LZ4) is stored in Column.Type instead of Column.Codec, while a leading COMMENT causes parsing to fail. This bug predates AfterShip#337. Recognize COMMENT, CODEC and TTL as modifiers when the type is omitted, preserving their AST fields through formatting and reparsing. Preserve explicit-type parsing and duplicate-modifier rejection, and regenerate the AST and formatting fixtures for the affected ALTER statements. Assistant-By GPT-6
git-hulk
added a commit
that referenced
this pull request
Oct 28, 2026
ALTER TABLE ... MODIFY COLUMN can reject valid modifier-only changes or store a modifier as the column type. Modifier keywords are treated as type names when the declaration omits its data type. For example, CODEC(LZ4) is stored in Column.Type instead of Column.Codec, while a leading COMMENT causes parsing to fail. This bug predates #337. Recognize COMMENT, CODEC and TTL as modifiers when the type is omitted, preserving their AST fields through formatting and reparsing. Preserve explicit-type parsing and duplicate-modifier rejection, and regenerate the AST and formatting fixtures for the affected ALTER statements. Assistant-By GPT-6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow the existing COMMENT, CODEC and TTL column modifiers in any order in CREATE TABLE, ALTER ADD COLUMN and ALTER MODIFY COLUMN.
The parser currently expects COMMENT before CODEC, but the formatter writes CODEC before COMMENT. A definition with both modifiers can parse successfully and then fail when its formatted output is parsed again.
Verification
make testpasses with Go 1.21.13 and Go 1.25.1, including race and compatibility tests. Go 1.21 used external linking for the local macOS linker requirement.make lintpasses with golangci-lint 1.64.5. The CI-pinned 1.53.3 binary was not used locally.ClickHouse 26.8's column parser accepts these trailing modifiers in any order and rejects duplicates. Its formatter uses COMMENT, CODEC, TTL order.
Canonical output was also accepted by the available native ClickHouse 26.2.1.1089 formatter. Noncanonical input ordering was checked against the 26.8 source, not a running 26.8 binary; the older binary rejects that input ordering.