Skip to content

Conversation

@kssumin
Copy link

@kssumin kssumin commented Oct 13, 2025

Fixes #10476

Changes

This PR enables ALTER TABLE ... RENAME TO and RENAME TABLE statements for sharding and broadcast tables.

Implementation details

  • Removed restrictions that previously blocked RENAME operations on sharding/broadcast tables
  • Added validation to prevent new table names from conflicting with existing sharding tables or schema tables
  • Added renameTables() method to MetaDataManagerPersistService interface for metadata management
  • Implemented rename logic in both ClusterMetaDataManagerPersistService and StandaloneMetaDataManagerPersistService
  • Updated AlterTablePushDownMetaDataRefresher and RenameTablePushDownMetaDataRefresher to handle rename operations
  • Added comprehensive test coverage with 8 test cases

Behavior

  • Single tables: Physical rename + automatic rule update
  • Sharding/Broadcast tables: Physical rename works; rules must be updated manually via DistSQL (consistent with DROP TABLE and CREATE TABLE behavior)

Files changed

Checker Classes (Remove restrictions + Add validation):

  • ShardingAlterTableSupportedChecker.java
  • ShardingRenameTableSupportedChecker.java
  • ShardingAlterTableSupportedCheckerTest.java
  • ShardingRenameTableSupportedCheckerTest.java

Metadata Management (Add renameTables method):

  • MetaDataManagerPersistService.java (interface)
  • ClusterMetaDataManagerPersistService.java (implementation)
  • StandaloneMetaDataManagerPersistService.java (implementation)

Metadata Refreshers (Handle RENAME operations):

  • AlterTablePushDownMetaDataRefresher.java
  • RenameTablePushDownMetaDataRefresher.java

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.
  • I have updated the Release Notes of the current development version. For more details, see Update Release Note

* Remove restrictions in ShardingAlterTableSupportedChecker and ShardingRenameTableSupportedChecker
* Add validation to prevent conflicts with existing sharding tables
* Add renameTables() method to MetaDataManagerPersistService interface
* Implement metadata refresh for table rename operations in both cluster and standalone modes
* Add comprehensive test coverage for rename table operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support sharding tables and broadcast tables to execute ALTER TABLE ... RENAME TO ... statement

1 participant