Skip to content

Conversation

@brfrn169
Copy link
Collaborator

@brfrn169 brfrn169 commented Nov 13, 2025

Description

This PR continues the refactoring of JdbcAdmin (following #3121).

Related issues and/or PRs

Changes made

  • Adjusted the timing of metadata schema creation and deletion.
  • Renamed tableExistsInternal()to internalTableExists().

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • 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

N/A

@brfrn169 brfrn169 self-assigned this Nov 13, 2025
Copilot AI review requested due to automatic review settings November 13, 2025 08:17
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 continues the refactoring of the JdbcAdmin component, focusing on improving the clarity and control over metadata schema management. It centralizes the creation and deletion of the metadata schema within JdbcAdmin itself, ensuring that the schema is created explicitly when needed and removed only when truly empty. Additionally, it standardizes the naming of internal table existence check methods for better consistency.

Highlights

  • Metadata Schema Creation Timing: The timing of metadata schema creation has been adjusted. Instead of being created implicitly when the namespaces table is created, the metadata schema is now explicitly created earlier in the process, such as during namespace or table creation, import, repair, or upgrade operations within JdbcAdmin.
  • Method Renaming: The internal method tableExistsInternal() has been consistently renamed to internalTableExists() across DynamoAdmin, JdbcAdmin, NamespaceMetadataService, and TableMetadataService. Similarly, the corresponding RDB engine strategy method tableExistsInternalTableCheckSql() has been renamed to internalTableExistsCheckSql().
  • Code Cleanup in NamespaceMetadataService: Redundant calls to createSchemaIfNotExists and deleteMetadataSchema have been removed from NamespaceMetadataService as the responsibility for metadata schema management has been centralized in JdbcAdmin.
  • Test Adjustments: Integration and unit tests have been updated to reflect the changes in metadata schema creation timing and method names, ensuring that the new logic is correctly tested and verified.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 continues the refactoring of JdbcAdmin. The main changes are adjusting the timing of metadata schema creation to be lazy and renaming tableExistsInternal() to internalTableExists() for better clarity. The changes look good and improve the code structure. I've found a minor issue in the test updates for SQLite where the mocking seems incorrect. Please see my detailed comment.

Copilot finished reviewing on behalf of brfrn169 November 13, 2025 08:21
Copy link
Contributor

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 continues the refactoring of JdbcAdmin by improving the structure and timing of metadata schema management, and renaming a method for better clarity.

  • Renamed tableExistsInternal() to internalTableExists() for improved naming consistency
  • Moved metadata schema creation responsibility from NamespaceMetadataService to JdbcAdmin level for better separation of concerns
  • Adjusted metadata schema deletion to occur at the JdbcAdmin level after namespace operations

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/src/main/java/com/scalar/db/storage/jdbc/JdbcAdmin.java Added createMetadataSchemaIfNotExists() and deleteMetadataSchemaIfEmpty() methods; renamed tableExistsInternal() to internalTableExists(); added metadata schema creation calls before operations that require it
core/src/main/java/com/scalar/db/storage/jdbc/NamespaceMetadataService.java Removed metadata schema creation and deletion logic, now handled at JdbcAdmin level; renamed tableExistsInternal() to internalTableExists()
core/src/main/java/com/scalar/db/storage/jdbc/TableMetadataService.java Renamed tableExistsInternal() to internalTableExists()
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineStrategy.java Renamed interface method tableExistsInternalTableCheckSql() to internalTableExistsCheckSql()
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineMysql.java Renamed method tableExistsInternalTableCheckSql() to internalTableExistsCheckSql()
core/src/main/java/com/scalar/db/storage/jdbc/RdbEnginePostgresql.java Renamed method tableExistsInternalTableCheckSql() to internalTableExistsCheckSql()
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineOracle.java Renamed method tableExistsInternalTableCheckSql() to internalTableExistsCheckSql()
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineSqlServer.java Renamed method tableExistsInternalTableCheckSql() to internalTableExistsCheckSql()
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineSqlite.java Renamed method tableExistsInternalTableCheckSql() to internalTableExistsCheckSql()
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineDb2.java Renamed method tableExistsInternalTableCheckSql() to internalTableExistsCheckSql()
core/src/main/java/com/scalar/db/storage/dynamo/DynamoAdmin.java Renamed method tableExistsInternal() to internalTableExists() for consistency
core/src/test/java/com/scalar/db/storage/jdbc/JdbcAdminTest.java Updated test parameter ordering to match new execution flow; added mocks for metadata schema operations; removed obsolete metadata schema creation mocks from createNamespacesTableIfNotExists tests
core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminTestUtils.java Updated to use renamed method internalTableExistsCheckSql()
core/src/integration-test/java/com/scalar/db/storage/multistorage/MultiStorageAdminTestUtils.java Updated to use renamed method internalTableExistsCheckSql()
Comments suppressed due to low confidence (1)

core/src/test/java/com/scalar/db/storage/jdbc/JdbcAdminTest.java:3974

  • This Statement is not always closed on method exit.
    verify(adminSpy).createNamespacesTableIfNotExists(connection);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@Torch3333 Torch3333 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
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.

The code looks good, so I'm approving it.
But, can you clarify the reason for the changes?

@brfrn169 brfrn169 requested review from komamitsu and removed request for KodaiD November 14, 2025 05:49
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 👍 other than @feeblefakie's comment.

@brfrn169 brfrn169 merged commit a117037 into master Nov 14, 2025
203 of 208 checks passed
@brfrn169 brfrn169 deleted the refactor-JdbcAdmin2 branch November 14, 2025 09:53
brfrn169 added a commit that referenced this pull request Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants