Skip to content

Cherry pick #114188 to 26.6: Ignore redundant parentheses in stored table definitions - #114654

Merged
robot-ch-test-poll2 merged 11 commits into
backport/26.6/114188from
cherrypick/26.6/114188
Aug 13, 2026
Merged

robot-ch-test-poll2 merged 11 commits into
backport/26.6/114188from
cherrypick/26.6/114188

Conversation

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

Original pull-request #114188

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 10 commits August 10, 2026 16:55
The definition expressions of a table (keys, `TTL`, indices, projections,
constraints, column defaults) are stored in ZooKeeper as text and compared as
text. #92340 made the AST remember the redundant parentheses the user wrote, so
`PARTITION BY (a)` stopped comparing equal to `PARTITION BY a`, and
`ATTACH`/`REPLACE`/`MOVE PARTITION FROM` and adding a replica started to fail.

Format those definitions with a new `ignore_redundant_parentheses` mode, which
gives back the text every server produced before the parentheses were a part of
the AST. What the user wrote is still stored in the table metadata and still
shown by `SHOW CREATE`; only the comparisons and the Keeper payload became
insensitive to it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ageQueue metadata

The `columns` field of the ObjectStorageQueue metadata in ZooKeeper was
compared with the local serialization verbatim, so a queue table created
by a version that kept the redundant parentheses of the user in a column
`DEFAULT`, `CODEC` or `TTL` expression (26.5-26.7) would fail with
`METADATA_MISMATCH` on a server that does not store them (and the other
way around). When the strings differ, compare the parsed
`ColumnsDescription` structurally, like `StorageKeeperMap` already does.

Co-Authored-By: Claude Fable 5 <[email protected]>
… when reusing a partially created replica

A retry of a partially created replica could find `/metadata` and `/columns` written
by a server version with a different (redundantly parenthesized) spelling of the same
table definition; the raw string comparison in `createReplicaAttempt` then failed with
`REPLICA_ALREADY_EXISTS`. Fall back to structural comparison
(`ReplicatedMergeTreeTableMetadata::checkEquals` / `ColumnsDescription::parse`)
when the texts differ.

Co-Authored-By: Claude Fable 5 <[email protected]>
…spellings

The test hand-crafts the ZooKeeper nodes of a replica as a 26.5..26.7 server
would have left them after failing between the ZooKeeper transaction and saving
the local metadata: the same definitions, spelled with redundant parentheses.
Retrying `CREATE TABLE` must reuse the empty replica instead of throwing
`REPLICA_ALREADY_EXISTS`.

Co-Authored-By: Claude Fable 5 <[email protected]>
…adata propagate

Per review: do not swallow exceptions in `createReplicaAttempt` when comparing the
`metadata` and `columns` of an existing empty replica. A structural mismatch or an
unparseable node now throws (e.g. `METADATA_MISMATCH`), which describes the problem
better than the `REPLICA_ALREADY_EXISTS` of the fall-through create attempt. This
also resolves the style-check finding about silent `catch (...)`.

Co-Authored-By: Claude Fable 5 <[email protected]>
…04850 test

The style check requires shell tests to include it in `ReplicatedMergeTree` paths
to avoid overlaps between concurrent test runs.

Co-Authored-By: Claude Fable 5 <[email protected]>
…tored-metadata

Ignore redundant parentheses in stored table definitions
@robot-ch-test-poll robot-ch-test-poll added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Aug 13, 2026
…ypick/26.6/114188

# Conflicts:
#	src/Parsers/IAST.cpp
#	src/Storages/StorageReplicatedMergeTree.cpp
@alexey-milovidov

Copy link
Copy Markdown
Member

Conflicts resolved. The change itself is taken verbatim - the resulting diff against backport/26.6/114188 is the same 18 files as #114188.

Two conflicts, both from surrounding code that differs from master, not from the change itself: the #if defined(CLICKHOUSE_PARSER_NO_FORMATTING) guard around the body of formatWithPossiblyHidingSensitiveData, which this branch does not have and which is therefore not taken; and in StorageReplicatedMergeTree::alter, where the new comment landed on the applyMetadataChangesToCreateQuery validation block that this branch still has - the block is kept and the comment goes after it.

All 11 changed translation units were compile-checked against this branch's sources.

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

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants