-
Notifications
You must be signed in to change notification settings - Fork 40
Add rename column #2990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rename column #2990
Conversation
...ation-test/java/com/scalar/db/storage/cassandra/CassandraAdminPermissionIntegrationTest.java
Show resolved
Hide resolved
core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminIntegrationTest.java
Show resolved
Hide resolved
There was a problem hiding this 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 theAdmin
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.
core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitAdmin.java
Show resolved
Hide resolved
…y or index key columns
62b9b81
to
bf367a6
Compare
...gration-test/src/main/java/com/scalar/db/api/DistributedStorageAdminIntegrationTestBase.java
Show resolved
Hide resolved
There was a problem hiding this 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>
There was a problem hiding this 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.
4614a51
to
d1542ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
There was a problem hiding this 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!
core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminIntegrationTest.java
Show resolved
Hide resolved
f819cd2
to
c03a8e0
Compare
There was a problem hiding this 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!
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineStrategy.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Toshihiro Suzuki <brfrn169@gmail.com>
@Torch3333 I'll merge this. Please take a look when you are back! |
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
ifNotExists
in add column #2960Changes made
renameColumn
method in theAdmin
interface.Checklist
Additional notes (optional)
N/A
Release notes
Added support for renaming columns in ScalarDB.