Skip to content

Conversation

KodaiD
Copy link
Contributor

@KodaiD KodaiD commented Sep 21, 2025

Description

This PR adds support for renaming tables in ScalarDB.

Currently, ScalarDB does not support renaming tables and users must recreate tables to rename tables. This feature will provide more flexibility in managing database schemas without requiring recreating tables.

Related issues and/or PRs

Changes made

  • Added renameTable method in the Admin interface.
  • Added unit tests for the method.
  • Added integration tests for the method.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

Added support for renaming tables in ScalarDB.

@KodaiD KodaiD self-assigned this Sep 21, 2025
@KodaiD KodaiD added the enhancement New feature or request label Sep 21, 2025
@KodaiD
Copy link
Contributor Author

KodaiD commented Sep 21, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for renaming tables in ScalarDB. The changes include adding a renameTable method to the Admin interface and implementing it for various storage backends. For storages that do not support table renaming (Cassandra, CosmosDB, DynamoDB), an UnsupportedOperationException is thrown. For JDBC-based storages, the functionality is implemented using native SQL commands. The PR also includes comprehensive unit and integration tests for the new feature. The changes are well-implemented, but I have one suggestion to improve consistency in error handling.

@KodaiD KodaiD marked this pull request as ready for review September 22, 2025 02:43
@Copilot Copilot AI review requested due to automatic review settings September 22, 2025 02:43
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive support for renaming tables in ScalarDB by implementing the renameTable method across all admin interfaces and storage implementations. It includes proper validation for existing source tables and prevents conflicts with existing destination table names.

  • Added renameTable method to the Admin interface with proper error handling
  • Implemented the functionality across all storage adapters (JDBC, Cassandra, DynamoDB, Cosmos DB)
  • Added comprehensive test coverage including unit tests and integration tests

Reviewed Changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core/src/main/java/com/scalar/db/api/Admin.java Added renameTable method definition to the Admin interface
core/src/main/java/com/scalar/db/storage/jdbc/JdbcAdmin.java Implemented renameTable with table metadata handling and SQL execution
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngine*.java Added database-specific SQL generation for table renaming across all RDB engines
core/src/main/java/com/scalar/db/storage/*/Admin.java Added UnsupportedOperationException for non-JDBC storages (Cassandra, DynamoDB, Cosmos)
core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java Added validation logic for table existence and conflicts
integration-test/src/main/java/**/Test.java Added comprehensive integration tests for all scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@KodaiD KodaiD requested a review from Copilot September 22, 2025 02:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 45 out of 45 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@KodaiD KodaiD requested review from a team, Torch3333, brfrn169, feeblefakie and komamitsu and removed request for a team September 22, 2025 04:05
@KodaiD
Copy link
Contributor Author

KodaiD commented Sep 22, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for renaming tables. The changes look good overall, with a new renameTable method in the Admin interface and implementations for various storage backends. I've found a couple of areas for improvement. One is a missing check for the existence of the new table name in ConsensusCommitAdmin, which could lead to unexpected behavior. The other is an opportunity to use a centralized error message for consistency in JdbcAdmin. Please see my detailed comments.

@KodaiD KodaiD requested a review from Copilot September 22, 2025 09:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 45 out of 45 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@brfrn169 brfrn169 requested a review from josh-wong September 24, 2025 06:45
Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

Although it’s not directly related to this PR, we might need to revisit the repairTable logic. The repairTable method is used when DDL operations fail, and since we’re extending alter table operations, we may encounter more failure cases that need to be handled.

Could you please take a look at it when you have time? 🙇

Copy link
Member

@josh-wong josh-wong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!🙇🏻‍♂️

Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@brfrn169
Copy link
Collaborator

@KodaiD Could you please fix the conflicts?

@brfrn169 brfrn169 merged commit bb3de17 into master Sep 25, 2025
56 checks passed
@brfrn169 brfrn169 deleted the add-rename-table branch September 25, 2025 07:36
@KodaiD KodaiD mentioned this pull request Oct 2, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants