Skip to content

[Cherry-pick to branch-1.3] [#11803] fix(clickhouse): add ON CLUSTER support for ALTER TABLE (#11807) - #11827

Merged
yuqi1129 merged 1 commit into
branch-1.3from
cherry-pick-c27520bd-to-branch-1.3
Jul 1, 2026
Merged

[Cherry-pick to branch-1.3] [#11803] fix(clickhouse): add ON CLUSTER support for ALTER TABLE (#11807)#11827
yuqi1129 merged 1 commit into
branch-1.3from
cherry-pick-c27520bd-to-branch-1.3

Conversation

@github-actions

Copy link
Copy Markdown

Cherry-pick Information:

  • Original commit: c27520b
  • Target branch: branch-1.3
  • Status: ✅ Clean cherry-pick (no conflicts)

)

### 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>
@github-actions github-actions Bot added the cherry-pick Automatically opened cherry-pick PR label Jun 30, 2026
@github-actions
github-actions Bot requested a review from jerryshao June 30, 2026 11:17
@yuqi1129
yuqi1129 merged commit 30ee893 into branch-1.3 Jul 1, 2026
32 checks passed
@yuqi1129
yuqi1129 deleted the cherry-pick-c27520bd-to-branch-1.3 branch July 1, 2026 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick Automatically opened cherry-pick PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants