-
Notifications
You must be signed in to change notification settings - Fork 40
Add alter column type #3028
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 alter column type #3028
Conversation
/gemini review |
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 adds support for altering column types in ScalarDB, a significant feature enhancement. The changes are extensive, touching the admin interfaces, various storage implementations (JDBC, Cassandra, Cosmos, DynamoDB), and transaction layers. The implementation is mostly solid, with good test coverage. I've identified a few areas for improvement, including a bug with a duplicated error code, a minor inconsistency in exception handling, and opportunities to improve code readability and remove redundancy in tests. Overall, this is a great contribution.
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineDb2.java
Outdated
Show resolved
Hide resolved
...gration-test/src/main/java/com/scalar/db/api/DistributedStorageAdminIntegrationTestBase.java
Show resolved
Hide resolved
d3c7a1c
to
64fdf4f
Compare
/gemini review |
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 significant new feature: altering column types. The changes are extensive, touching the admin interfaces, common logic, and specific implementations for various storage backends. The core logic for handling type alterations and the addition of numerous integration tests are commendable. My review focuses on improving resource management in the new tests and ensuring consistent error handling. Overall, this is a solid contribution that enhances the flexibility of schema management in ScalarDB.
...est/java/com/scalar/db/storage/jdbc/ConsensusCommitAdminIntegrationTestWithJdbcDatabase.java
Show resolved
Hide resolved
...est/java/com/scalar/db/storage/jdbc/ConsensusCommitAdminIntegrationTestWithJdbcDatabase.java
Outdated
Show resolved
Hide resolved
...ntegration-test/java/com/scalar/db/storage/jdbc/JdbcAdminCaseSensitivityIntegrationTest.java
Outdated
Show resolved
Hide resolved
...ntegration-test/java/com/scalar/db/storage/jdbc/JdbcAdminCaseSensitivityIntegrationTest.java
Outdated
Show resolved
Hide resolved
core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminIntegrationTest.java
Outdated
Show resolved
Hide resolved
...alar/db/storage/jdbc/SingleCrudOperationTransactionAdminIntegrationTestWithJdbcDatabase.java
Outdated
Show resolved
Hide resolved
...alar/db/storage/jdbc/SingleCrudOperationTransactionAdminIntegrationTestWithJdbcDatabase.java
Outdated
Show resolved
Hide resolved
...ntegration-test/java/com/scalar/db/transaction/jdbc/JdbcTransactionAdminIntegrationTest.java
Outdated
Show resolved
Hide resolved
...ntegration-test/java/com/scalar/db/transaction/jdbc/JdbcTransactionAdminIntegrationTest.java
Outdated
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 altering column types in ScalarDB, providing more flexibility in managing database schemas without requiring table recreation.
- Added
alterColumnType
method to the Admin interface and all implementations - Implemented type conversion validation with storage-specific limitations
- Added comprehensive unit and integration tests for the new functionality
Reviewed Changes
Copilot reviewed 54 out of 54 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
core/src/main/java/com/scalar/db/api/Admin.java |
Adds alterColumnType method to the Admin interface |
core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java |
Implements type conversion validation logic |
core/src/main/java/com/scalar/db/storage/jdbc/JdbcAdmin.java |
Implements JDBC-specific column type alteration |
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngine*.java |
Adds database-specific SQL generation for column type changes |
core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitAdmin.java |
Handles column type changes for both main and before-image columns |
Various test files | Adds comprehensive unit and integration tests |
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/storage/jdbc/RdbEngineDb2.java
Outdated
Show resolved
Hide resolved
...alar/db/storage/jdbc/SingleCrudOperationTransactionAdminIntegrationTestWithJdbcDatabase.java
Show resolved
Hide resolved
...est/java/com/scalar/db/storage/jdbc/ConsensusCommitAdminIntegrationTestWithJdbcDatabase.java
Show resolved
Hide resolved
...est/java/com/scalar/db/storage/jdbc/ConsensusCommitAdminIntegrationTestWithJdbcDatabase.java
Show resolved
Hide resolved
/gemini review |
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 valuable feature for altering column types in ScalarDB, enhancing schema management flexibility. The implementation is well-structured, with a new alterColumnType
method added to the Admin
interface and correctly implemented across various storage backends. For databases that do not support this feature, such as Cassandra, Cosmos DB, and DynamoDB, the implementation appropriately throws an UnsupportedOperationException
. The JDBC storage implementations are particularly thorough, covering specific SQL dialects and limitations for MySQL, PostgreSQL, SQL Server, Oracle, and Db2. The addition of comprehensive unit and integration tests ensures the reliability of this new functionality. Overall, this is a solid contribution. I have one minor suggestion to improve code readability.
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineDb2.java
Outdated
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.
Overall, looking good.
Left some suggestions. PTAL!
core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java
Show resolved
Hide resolved
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineStrategy.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineDb2.java
Outdated
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.
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.
Overall LGTM. Left a few comments. PTAL!
...ion-test/src/main/java/com/scalar/db/api/DistributedTransactionAdminIntegrationTestBase.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineStrategy.java
Outdated
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.
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.
LGTM, thank you!
/gemini review |
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 support for altering column types in ScalarDB, a significant feature enhancement. The changes are extensive, touching the core Admin API, various storage implementations (JDBC, Cassandra, Cosmos, DynamoDB), and transaction managers. The implementation for JDBC databases is thorough, with specific handling for different RDB engines like Oracle, DB2, and SQLite. For storages that do not support this feature, it's correctly disabled. The integration and unit tests are comprehensive, covering various scenarios and database-specific behaviors. I've found one issue in the ConsensusCommitAdmin implementation that needs to be addressed. Overall, this is a well-executed PR that adds valuable flexibility to schema management.
core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitAdmin.java
Show resolved
Hide resolved
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineOracle.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineDb2.java
Outdated
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.
LGTM! Thank you!
@Torch3333 I'll merge this PR. Please take a look when you are back! |
Description
This PR adds support for altering column types in ScalarDB.
Currently, ScalarDB does not support altering column types and users must recreate tables to do so. 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
alterColumnType
method in the Admin interface.Checklist
Additional notes (optional)
This PR does not consider imported tables. I will create another PR to handle those.
Release notes
Added support for altering column types in ScalarDB.