Support SETTINGS in ALTER TABLE ADD INDEX and fix IF NOT EXISTS placement - #319
Merged
git-hulk merged 1 commit intoSep 4, 2026
Merged
Conversation
…ment
ADD INDEX had no SETTINGS clause, so a statement such as
ALTER TABLE t ADD INDEX IF NOT EXISTS idx c TYPE minmax
GRANULARITY 1 SETTINGS alter_sync = 2
failed to parse, while ADD COLUMN and the partition clauses already
accepted one. Parse it the same way they do.
The formatter also wrote the clause as `ADD IF NOT EXISTS INDEX`, which
ClickHouse rejects, so formatted output could not be parsed again. Split
the part of TableIndex.FormatSQL that follows the INDEX keyword so
ALTER TABLE can emit `ADD INDEX IF NOT EXISTS` instead.
Both forms were verified against clickhouse-local 26.8.2.7.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Lance726
marked this pull request as draft
September 4, 2026 03:02
Lance726
marked this pull request as ready for review
September 4, 2026 03:22
git-hulk
approved these changes
Sep 4, 2026
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.
Two fixes to
ALTER TABLE … ADD INDEX.It was the only alter clause that did not accept
SETTINGS, so this failed to parse:The formatter also wrote
ADD IF NOT EXISTS INDEX, which ClickHouse rejects — formatted output could not be parsed again. It now writesADD INDEX IF NOT EXISTS.Verified against
clickhouse-local26.8.2.7.AlterTableAddIndex.Settingsis new; no existing field changes.