Skip to content

Allow parentheses around the SELECT part of INSERT SELECT to fix the "Inconsistent formatting" problem - #95057

Merged
alexey-milovidov merged 1 commit into
masterfrom
insert-select-parentheses
Jan 25, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
insert-select-parentheses

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jan 24, 2026 •

Copy link
Copy Markdown
Member

Previously, queries like INSERT INTO t (c) (SELECT 1) were rejected by the parser. This was problematic because the formatter could produce such output when formatting queries with UNION/EXCEPT/INTERSECT, making the formatted output unparseable.

The fix adds ( as a valid indicator that a SELECT query follows in ParserInsertQuery. The existing ParserSelectWithUnionQuery already handles parenthesized selects through ParserSubquery.

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

See the first example in #93861

Version info

  • Merged into: 26.1.1.826

Previously, queries like `INSERT INTO t (c) (SELECT 1)` were rejected
by the parser. This was problematic because the formatter could produce
such output when formatting queries with UNION/EXCEPT/INTERSECT, making
the formatted output unparseable.

The fix adds `(` as a valid indicator that a SELECT query follows in
`ParserInsertQuery`. The existing `ParserSelectWithUnionQuery` already
handles parenthesized selects through `ParserSubquery`.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jan 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [855aaba]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_tsan, sequential, 2/2) failure
00170_s3_cache FAIL cidb
ThreadSanitizer: data race (STID: 2981-3c7d) FAIL cidb, issue
Integration tests (amd_tsan, 3/6) failure
test_ttl_replicated/test.py::test_ttl_compatibility[node_left1-node_right1-1] FAIL cidb
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: (STID: 1941-1bfa) FAIL cidb, issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

post-approved Approved, but after the PR is merged. pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants