Repository navigation
Cherry pick #114188 to 26.3: Ignore redundant parentheses in stored table definitions - #114652
Conversation
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]>
…es-in-stored-metadata
…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]>
…es-in-stored-metadata
… 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]>
…es-in-stored-metadata
…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
…ypick/26.3/114188 Only the part of #114188 that applies to 26.3 is taken. The `parenthesized` flag of `IAST` was introduced by #92340 in 26.5, so 26.3 never writes a table definition with the redundant parentheses the user has written, and the bug the pull request fixes cannot happen here. Everything built on `IAST::FormatSettings::ignore_redundant_parentheses` - `IAST::formatIgnoringRedundantParentheses` and all of its call sites - would be dead code on this branch, and the tests `04836_parenthesized_definitions_attach_partition_from` and `04837_parenthesized_definitions_replicated_metadata` assert that `SHOW CREATE` prints the parentheses back, which is 26.5 and later behavior. Those are left out. What is taken are the two places that have to accept a definition stored by 26.5..26.7, which 26.3 needs in order to read such a table at all: - `ObjectStorageQueueTableMetadata::checkImmutableFieldsEquals` compares the `columns` payload structurally when the stored and the local text differ, covered by the unit test `ObjectStorageQueueTableMetadata.ColumnsComparisonIgnoresRedundantParentheses`. - `StorageReplicatedMergeTree::createReplicaAttempt` recognizes an already-created empty replica by comparing its `/metadata` and `/columns` structurally, covered by `04850_parenthesized_definitions_replica_recovery`. Both fail on 26.3 without this change.
|
Conflicts resolved. Only the part of #114188 that applies to The What is taken are the two places that have to accept a definition stored by
Both of these fail on If you would rather not carry the two tolerance fixes on The changed translation units were compile-checked against this branch's sources. |
|
Closing: #114188 is not needed on The bug it fixes needs The reduced variant pushed to this branch earlier (the two structural-comparison fixes that let |
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-picklocally.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:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job