Skip to content

Conversation

KodaiD
Copy link
Contributor

@KodaiD KodaiD commented Aug 29, 2025

Description

This PR adds support for renaming columns in ScalarDB.

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

Related issues and/or PRs

Changes made

  • Added renameColumn 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 columns in ScalarDB.

@KodaiD KodaiD self-assigned this Aug 29, 2025
@KodaiD KodaiD added the enhancement New feature or request label Aug 29, 2025
@KodaiD KodaiD requested a review from Copilot September 8, 2025 10:15
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 support for renaming columns in ScalarDB, addressing a limitation where users had to recreate entire tables to rename columns. The feature provides a new renameColumn method across the admin interfaces and includes comprehensive validation, error handling, and database-specific implementations.

Key changes:

  • Added renameColumn method to the Admin interface and all implementing classes
  • Implemented database-specific SQL generation for column and index renaming across JDBC engines
  • Added comprehensive integration and unit tests covering various scenarios including primary keys, secondary indexes, and error cases

Reviewed Changes

Copilot reviewed 47 out of 47 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
core/src/main/java/com/scalar/db/api/Admin.java Added renameColumn method definition to the main Admin interface
core/src/main/java/com/scalar/db/storage/jdbc/JdbcAdmin.java Core implementation with metadata updates and index renaming logic
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngine*.java Database-specific SQL generation for column and index renaming
core/src/main/java/com/scalar/db/storage/cassandra/CassandraAdmin.java Cassandra-specific implementation using SchemaBuilder
core/src/main/java/com/scalar/db/storage/dynamo/DynamoAdmin.java Throws UnsupportedOperationException for DynamoDB
core/src/main/java/com/scalar/db/storage/cosmos/CosmosAdmin.java Throws UnsupportedOperationException for Cosmos DB
core/src/main/java/com/scalar/db/common/CheckedDistributedStorageAdmin.java Validation logic for table/column existence and conflicts
integration-test/src/main/java/com/scalar/db/api/DistributedStorageAdminIntegrationTestBase.java Comprehensive integration tests for various rename scenarios

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

@KodaiD KodaiD marked this pull request as ready for review September 9, 2025 00:44
@KodaiD KodaiD requested review from a team, Torch3333, brfrn169, feeblefakie and komamitsu and removed request for a team September 9, 2025 00:44
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.

Although I left one minor suggestion on the error message, LGTM! Thank you!

Co-authored-by: Hiroyuki Yamada <mogwaing@gmail.com>
@KodaiD KodaiD requested a review from komamitsu September 9, 2025 05:20
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 introduces a renameColumn feature to ScalarDB, a valuable addition for schema management. The implementation covers various database backends, correctly handling cases where the feature is unsupported by throwing an UnsupportedOperationException. The integration tests are well-structured, disabling tests for unsupported databases.

I've identified a critical issue in the JdbcAdmin implementation that could lead to incorrect table metadata and subsequent query failures when renaming a column that is part of a multi-column primary key. I've also suggested a minor refactoring in CassandraAdmin to improve code clarity.

It would be beneficial to add a test case that covers renaming a column in a table with multiple partition or clustering keys to prevent regressions of the identified issue.

@KodaiD KodaiD requested a review from komamitsu September 10, 2025 04:44
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!

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.

Left a couple of comments. PTAL!

@KodaiD KodaiD requested a review from brfrn169 September 11, 2025 04:08
@KodaiD KodaiD requested a review from brfrn169 September 11, 2025 05:23
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.

Left a few comments. Other than that, LGTM! Thank you!

KodaiD and others added 2 commits September 11, 2025 17:20
@brfrn169
Copy link
Collaborator

@Torch3333 I'll merge this. Please take a look when you are back!

@brfrn169 brfrn169 merged commit 2e7cd60 into master Sep 11, 2025
104 of 108 checks passed
@brfrn169 brfrn169 deleted the add-rename-column branch September 11, 2025 12:07
@KodaiD KodaiD mentioned this pull request Sep 21, 2025
7 tasks
@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.

4 participants