-
Notifications
You must be signed in to change notification settings - Fork 332
[JDBC] Part3: Plumb JDBC module to quarkus #1371
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
Merged
flyrain
merged 11 commits into
apache:main
from
singhpk234:feature/integrate-jdbc-to-quarkus
Apr 26, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
800b946
Plumb admin pending Service E2E
singhpk234 530c9d6
Add E2E test for service
singhpk234 eece61a
fix bug
singhpk234 155f715
more review feedbacks
singhpk234 99928c1
Address yufei feedback
singhpk234 41291f4
Address feedbacks
singhpk234 4a2bf40
change the test impl
singhpk234 e28c052
Address feedbacks
singhpk234 5c9f323
Revert single DS from constructor
singhpk234 9bf2972
remove the exlusion
singhpk234 6835385
Address review feedback
singhpk234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
.../src/main/java/org/apache/polaris/extension/persistence/relational/jdbc/DatabaseType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.polaris.extension.persistence.relational.jdbc; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| public enum DatabaseType { | ||
| POSTGRES("postgres"), | ||
| H2("h2"); | ||
|
|
||
| private final String displayName; // Store the user-friendly name | ||
|
|
||
| DatabaseType(String displayName) { | ||
| this.displayName = displayName; | ||
| } | ||
|
|
||
| // Method to get the user-friendly display name | ||
| public String getDisplayName() { | ||
| return displayName; | ||
| } | ||
|
|
||
| public static DatabaseType fromDisplayName(String displayName) { | ||
| return switch (displayName.toLowerCase(Locale.ROOT)) { | ||
| case "h2" -> DatabaseType.H2; | ||
| case "postgresql" -> DatabaseType.POSTGRES; | ||
| default -> throw new IllegalStateException("Unsupported DatabaseType: '" + displayName + "'"); | ||
| }; | ||
| } | ||
|
|
||
| public String getInitScriptResource() { | ||
| return String.format("%s/schema-v1.sql", this.getDisplayName()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,9 @@ | |
| import io.smallrye.common.annotation.Identifier; | ||
| import jakarta.annotation.Nullable; | ||
| import jakarta.enterprise.context.ApplicationScoped; | ||
| import jakarta.enterprise.inject.Instance; | ||
| import jakarta.inject.Inject; | ||
| import java.sql.Connection; | ||
| import java.sql.SQLException; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
@@ -37,6 +39,7 @@ | |
| import org.apache.polaris.core.entity.PolarisEntitySubType; | ||
| import org.apache.polaris.core.entity.PolarisEntityType; | ||
| import org.apache.polaris.core.entity.PolarisPrincipalSecrets; | ||
| import org.apache.polaris.core.persistence.AtomicOperationMetaStoreManager; | ||
| import org.apache.polaris.core.persistence.BasePersistence; | ||
| import org.apache.polaris.core.persistence.MetaStoreManagerFactory; | ||
| import org.apache.polaris.core.persistence.PolarisMetaStoreManager; | ||
|
|
@@ -46,7 +49,6 @@ | |
| import org.apache.polaris.core.persistence.dao.entity.BaseResult; | ||
| import org.apache.polaris.core.persistence.dao.entity.EntityResult; | ||
| import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult; | ||
| import org.apache.polaris.core.persistence.transactional.TransactionalMetaStoreManagerImpl; | ||
| import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider; | ||
| import org.apache.polaris.core.storage.cache.StorageCredentialCache; | ||
| import org.slf4j.Logger; | ||
|
|
@@ -68,10 +70,9 @@ public class JdbcMetaStoreManagerFactory implements MetaStoreManagerFactory { | |
| final Map<String, EntityCache> entityCacheMap = new HashMap<>(); | ||
| final Map<String, Supplier<BasePersistence>> sessionSupplierMap = new HashMap<>(); | ||
| protected final PolarisDiagnostics diagServices = new PolarisDefaultDiagServiceImpl(); | ||
| // TODO: Pending discussion of if we should have one Database per realm or 1 schema per realm | ||
| // or realm should be a primary key on all the tables. | ||
| @Inject DataSource dataSource; | ||
|
|
||
| @Inject PolarisStorageIntegrationProvider storageIntegrationProvider; | ||
| @Inject Instance<DataSource> dataSource; | ||
|
|
||
| protected JdbcMetaStoreManagerFactory() {} | ||
|
|
||
|
|
@@ -86,7 +87,7 @@ protected PrincipalSecretsGenerator secretsGenerator( | |
| } | ||
|
|
||
| protected PolarisMetaStoreManager createNewMetaStoreManager() { | ||
| return new TransactionalMetaStoreManagerImpl(); | ||
| return new AtomicOperationMetaStoreManager(); | ||
| } | ||
|
|
||
| private void initializeForRealm( | ||
|
|
@@ -106,12 +107,16 @@ private void initializeForRealm( | |
| } | ||
|
|
||
| private DatasourceOperations getDatasourceOperations(boolean isBootstrap) { | ||
| DatasourceOperations databaseOperations = new DatasourceOperations(dataSource); | ||
| DatasourceOperations databaseOperations = new DatasourceOperations(dataSource.get()); | ||
| if (isBootstrap) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to recap: I believe it is preferable to run DDL from the dedicated |
||
| // TODO: see if we need to take script from Quarkus or can we just | ||
| // use the script committed in the repo. | ||
| try { | ||
| databaseOperations.executeScript("scripts/postgres/schema-v1-postgres.sql"); | ||
| DatabaseType databaseType; | ||
| try (Connection connection = dataSource.get().getConnection()) { | ||
| String productName = connection.getMetaData().getDatabaseProductName(); | ||
| databaseType = DatabaseType.fromDisplayName(productName); | ||
| } | ||
| databaseOperations.executeScript( | ||
| String.format("%s/schema-v1.sql", databaseType.getDisplayName())); | ||
singhpk234 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } catch (SQLException e) { | ||
| throw new RuntimeException( | ||
| String.format("Error executing sql script: %s", e.getMessage()), e); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.