Skip to content

Conversation

KodaiD
Copy link
Contributor

@KodaiD KodaiD commented Oct 2, 2025

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

Changes made

  • Added alterColumnType 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)

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.

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

KodaiD commented Oct 2, 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 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.

@KodaiD KodaiD force-pushed the add-alter-column-type branch from d3c7a1c to 64fdf4f Compare October 2, 2025 23:57
@KodaiD
Copy link
Contributor Author

KodaiD commented Oct 3, 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 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.

@KodaiD KodaiD marked this pull request as ready for review October 3, 2025 02:02
@Copilot Copilot AI review requested due to automatic review settings October 3, 2025 02:02
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 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.

@KodaiD
Copy link
Contributor Author

KodaiD commented Oct 3, 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 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.

@KodaiD KodaiD requested review from a team, Torch3333, brfrn169, feeblefakie and komamitsu and removed request for a team October 3, 2025 05:18
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.

Overall, looking good.
Left some suggestions. PTAL!

@KodaiD KodaiD requested a review from feeblefakie October 6, 2025 05:39
@brfrn169 brfrn169 requested a review from josh-wong October 7, 2025 01:34
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
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.

Overall LGTM. Left a few comments. PTAL!

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!

@KodaiD KodaiD requested review from brfrn169 and komamitsu October 7, 2025 06:13
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!

@KodaiD
Copy link
Contributor Author

KodaiD commented Oct 7, 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 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.

@KodaiD KodaiD requested a review from brfrn169 October 7, 2025 11:03
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!

@brfrn169
Copy link
Collaborator

brfrn169 commented Oct 8, 2025

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

@brfrn169 brfrn169 merged commit 53383a9 into master Oct 8, 2025
105 of 108 checks passed
@brfrn169 brfrn169 deleted the add-alter-column-type branch October 8, 2025 02:02
@KodaiD KodaiD mentioned this pull request Oct 9, 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.

5 participants