Y-Wakuta commented on code in PR #4281:
URL: https://github.com/apache/polaris/pull/4281#discussion_r3353828844


##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java:
##########
@@ -92,8 +94,19 @@ protected JdbcMetaStoreManagerFactory() {}
   @Produces
   @ApplicationScoped
   static DatasourceOperations produceDatasourceOperations(
-      Instance<DataSource> dataSource, RelationalJdbcConfiguration 
relationalJdbcConfiguration) {
-    return new DatasourceOperations(dataSource.get(), 
relationalJdbcConfiguration);
+      Instance<DataSource> defaultDataSource,
+      @Any Instance<DataSource> dataSources,
+      RelationalJdbcConfiguration relationalJdbcConfiguration) {
+    // Use a named DataSource if one is declared for the configured 
database-type;
+    // otherwise fall back to the default (shared by all PostgreSQL-driver 
backends).
+    DataSource ds =
+        relationalJdbcConfiguration
+            .databaseType()
+            .map(type -> dataSources.select(new DataSourceLiteral(type)))
+            .filter(Instance::isResolvable)
+            .map(Instance::get)
+            .orElseGet(defaultDataSource::get);

Review Comment:
   Thanks for the suggestion — fixed. produceDatasourceOperations now fails 
fast when database-type=mysql is set but the mysql named datasource isn't 
resolvable, with a message pointing to -PincludeMysqlDriver=true + 
quarkus.datasource.mysql.active=true + connection properties.
   
   Scoped to MySQL only by design: PostgreSQL/CockroachDB/H2 share the default 
(unnamed) datasource and have no named datasource of their own, so failing on 
"explicit type + unresolvable named datasource" would break their explicit 
config. MySQL is the only backend that requires a distinct named datasource — 
matching your "at least for mysql" note. The other backends keep the existing 
default-fallback behavior.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to