-
Notifications
You must be signed in to change notification settings - Fork 40
Introduce virtual tables in Storage abstraction #3180
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
Introduce virtual tables in Storage abstraction #3180
Conversation
Summary of ChangesHello @brfrn169, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Storage abstraction by introducing virtual tables, enabling the logical joining of two source tables on their primary keys. This feature simplifies data access for related entities stored separately, providing a unified view. It includes new administrative APIs for creation and metadata retrieval, backed by extensive validation and a dedicated metadata management service. The JDBC adapter fully implements this functionality, while other adapters are updated to reflect its current unavailability. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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 virtual tables, a significant and valuable feature for the storage abstraction layer. The implementation is comprehensive, covering API changes, validation logic, JDBC support, and extensive testing. The code is well-structured, and the validation for creating virtual tables is thorough, covering schema compatibility, name conflicts, and atomicity constraints. The handling of operations like put, delete, scan, and get on virtual tables in the JDBC adapter is well-designed.
I have a couple of minor suggestions for improving maintainability.
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 introduces virtual tables in the Storage abstraction layer, enabling a logical join of two source tables on their primary key. This allows related data stored in separate tables to be accessed as a single logical entity.
Key Changes:
- New API methods in
DistributedStorageAdminfor creating and querying virtual tables with support for INNER and LEFT_OUTER joins - Comprehensive validation logic in
CommonDistributedStorageAdminto ensure schema compatibility and prevent invalid configurations - Full JDBC implementation via
JdbcAdminusing database views, with metadata management throughVirtualTableMetadataService - Enhanced mutation handling in
JdbcDatabaseto automatically divide Put/Delete operations for virtual tables into corresponding operations on source tables - New integration test suite
DistributedStorageVirtualTablesIntegrationTestBasewith comprehensive test coverage
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 30 comments.
Show a summary per file
| File | Description |
|---|---|
DistributedStorageAdmin.java |
Adds virtual table API methods with multiple overloads |
VirtualTableInfo.java & VirtualTableJoinType.java |
New interfaces defining virtual table metadata and join types |
CommonDistributedStorageAdmin.java |
Implements validation logic for virtual table creation |
JdbcAdmin.java |
JDBC implementation with view creation, metadata management, and special handling for truncate/drop/index operations |
JdbcDatabase.java |
Mutation handling that divides virtual table operations into source table operations |
VirtualTableMetadataService.java |
Manages virtual table metadata storage in JDBC |
VirtualTableInfoManager.java |
Caches virtual table information with configurable expiration |
MultiStorageAdmin.java |
Validates virtual tables and source tables reside in same storage |
DistributedStorageVirtualTablesIntegrationTestBase.java |
Comprehensive integration tests for virtual table functionality |
CoreError.java |
Adds error codes for virtual table validation failures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
core/src/test/java/com/scalar/db/storage/jdbc/VirtualTableMetadataServiceTest.java
Show resolved
Hide resolved
core/src/test/java/com/scalar/db/storage/jdbc/VirtualTableMetadataServiceTest.java
Show resolved
Hide resolved
core/src/test/java/com/scalar/db/storage/jdbc/VirtualTableMetadataServiceTest.java
Show resolved
Hide resolved
core/src/test/java/com/scalar/db/storage/jdbc/VirtualTableMetadataServiceTest.java
Show resolved
Hide resolved
core/src/test/java/com/scalar/db/storage/jdbc/VirtualTableMetadataServiceTest.java
Show resolved
Hide resolved
core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java
Show resolved
Hide resolved
feeblefakie
left a comment
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 comments and suggestions.
PTAL!
core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java
Show resolved
Hide resolved
core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java
Show resolved
Hide resolved
core/src/main/java/com/scalar/db/storage/jdbc/VirtualTableMetadataService.java
Show resolved
Hide resolved
feeblefakie
left a comment
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
left a comment
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!
komamitsu
left a comment
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!
Description
This PR introduces virtual tables in the Storage abstraction layer. Virtual tables allow exposing a logical join of two source tables on their primary key, enabling related data stored in separate tables to be accessed as a single logical entity. Currently, only the JDBC adapter supports it.
Key Features:
Notes:
JDBC adapter implementation details
createVirtualTable()For example, suppose we have the following two tables:
Then we create the following view based on these source tables:
Whether to use
INNER JOINorLEFT OUTER JOINdepends on the specified join type.getVirtualTableInfo()getTableMetadata()for virtual tablesgetNamespaceTableNames()dropTable()truncateTable()for virtual tablescreateIndex()for virtual tablesdropIndex()for virtual tablesget()for virtual tablesscan()for virtual tablesput()for virtual tablesdelete()for virtual tablesmutate()for virtual tablesput()anddelete()For read operations, we execute the reads against the view, but for write operations, we directly update the source tables. This is because most databases don't support updatable views or have significant limitations.
Currently, some administrative operations for virtual tables and source tables are not supported.
Related issues and/or PRs
N/A
Changes made
DistributedStorageAdmin:createVirtualTable(): Multiple overloads with options for ifNotExists and custom optionsgetVirtualTableInfo(): Retrieve virtual table metadataCommonDistributedStorageAdminprovides comprehensive validation logicJdbcAdminwith view creationDistributedStorageVirtualTablesIntegrationTestBaseChecklist
Additional notes (optional)
N/A
Release notes
Introduced virtual tables in the Storage abstraction layer. Virtual tables allow exposing a logical join of two source tables on their primary key, enabling related data stored in separate tables to be accessed as a single logical entity.