[Cherry-pick to branch-1.3] [#11803] fix(clickhouse): add ON CLUSTER support for ALTER TABLE (#11807) - #11827
Merged
Conversation
) ### What changes were proposed in this pull request? - `generateAlterTableSql()` now checks `ON_CLUSTER` and `CLUSTER_NAME` table properties and injects `ON CLUSTER <clusterName>` into the ALTER TABLE SQL when both are set. - Adds `getOrCreateTable()` call for change types that do not otherwise require loading the table, so cluster metadata is available. - Adds null-safety for `properties()` access, consistent with `generateDropTableSql()`. - Omits `SYNC` (unlike `generateDropTableSql()`) because ClickHouse does not support synchronous ALTER operations. ### Why are the changes needed? Fix: #11803 Previously, `generateAlterTableSql()` always generated `ALTER TABLE ...` without `ON CLUSTER`. For tables created with `ON CLUSTER`, subsequent ALTER operations only affected the local node, causing schema divergence across cluster nodes. ### Does this PR introduce _any_ user-facing change? Yes. ALTER TABLE operations on clustered tables now propagate to all nodes in the cluster, preventing schema divergence. ### How was this patch tested? - `./gradlew :catalogs-contrib:catalog-jdbc-clickhouse:test --tests "org.apache.gravitino.catalog.clickhouse.operations.TestClickHouseTableOperationsCluster" -PskipITs` - `./gradlew :catalogs-contrib:catalog-jdbc-clickhouse:test --tests "org.apache.gravitino.catalog.clickhouse.integration.test.CatalogClickHouseClusterIT" -PskipDockerTests=false` --------- Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com> Co-authored-by: Chang-Tong <zdcheerful@hotmail.com> Co-authored-by: ArtificialIdoit <bill.sea@hotmail.com> Co-authored-by: cwq222 <15503804976@163.com>
yuqi1129
approved these changes
Jul 1, 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.
Cherry-pick Information:
branch-1.3