Repository navigation
Fix inconsistent AST formatting: reset parent_has_trailing_settings inside subqueries - #99938
Merged
Merged
Conversation
…nside subqueries The `parent_has_trailing_settings` flag in the formatting frame was propagating from parent queries (e.g. ALTER TABLE with SETTINGS) into nested subqueries, causing `ASTSelectWithUnionQuery` to wrap inner SELECT nodes in extra parentheses at every nesting level. This produced syntactically invalid output like `((SELECT ... SETTINGS ...))` that failed to re-parse, triggering 'Inconsistent AST formatting' exceptions. The fix resets `parent_has_trailing_settings` in `ASTSubquery::formatImplWithoutAlias`, since subquery parentheses provide a clear syntactic boundary — any SETTINGS appended by a parent `ASTQueryWithOutput` will come after the closing `)` and cannot be confused with a SELECT's own SETTINGS clause. This is consistent with the approach already used in `ASTCreateQuery`. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96563&sha=bc8e58f5947d1691a0291771b96b05462e9ecd4a&name_0=PR&name_1=BuzzHouse+%28amd_debug%29
1 task
Contributor
Avogar
approved these changes
Mar 18, 2026
alexey-milovidov
approved these changes
Mar 19, 2026
Contributor
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 100.00% (7/7, 0 noise lines excluded) |
1 task done
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.
The
parent_has_trailing_settingsflag in the formatting frame was propagating from parent queries (e.g. ALTER TABLE with SETTINGS) into nested subqueries, causingASTSelectWithUnionQueryto wrap inner SELECT nodes in extra parentheses at every nesting level. This produced syntactically invalid output like((SELECT ... SETTINGS ...))that failed to re-parse, triggering 'Inconsistent AST formatting' exceptions.The fix resets
parent_has_trailing_settingsinASTSubquery::formatImplWithoutAlias, since subquery parentheses provide a clear syntactic boundary — any SETTINGS appended by a parentASTQueryWithOutputwill come after the closing)and cannot be confused with a SELECT's own SETTINGS clause. This is consistent with the approach already used inASTCreateQuery.https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96563&sha=bc8e58f5947d1691a0291771b96b05462e9ecd4a&name_0=PR&name_1=BuzzHouse+%28amd_debug%29
#96563
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix "Inconsistent AST formatting" exception for
ALTER TABLE ... MODIFY QUERYwith nested subqueries containingSETTINGSwhen theALTERitself also hasSETTINGS.Documentation entry for user-facing changes
Version info
26.3.1.880