Y-Wakuta commented on code in PR #4281:
URL: https://github.com/apache/polaris/pull/4281#discussion_r3360016254
##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java:
##########
@@ -95,8 +97,39 @@ 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) {
+ Optional<String> configuredType =
relationalJdbcConfiguration.databaseType();
+
+ // MySQL is the only backend that requires a dedicated named DataSource
(it needs the GPL
+ // MySQL driver, which is opt-in at build time and inactive by default).
When MySQL is
+ // explicitly configured but its named DataSource is not resolvable, fail
fast with actionable
+ // guidance instead of silently falling back to the default
(PostgreSQL-driver) DataSource —
+ // that fallback would otherwise surface much later as a confusing
database-type mismatch.
+ String mysql = DatabaseType.MYSQL.getDisplayName();
+ if (configuredType.map(type ->
type.equalsIgnoreCase(mysql)).orElse(false)) {
+ Instance<DataSource> mysqlDataSource = dataSources.select(new
DataSourceLiteral(mysql));
Review Comment:
You're right, the asymmetry wasn't justified. This block is new since your
last review (added per a Copilot comment about failing fast when MySQL is
configured but its datasource isn't resolvable). I should have flagged it
explicitly, sorry. I've unified it: the named DataSource is now selected by the
exact configuredType string in all cases, and the case-insensitive comparison
is gone. The only spot that still references the MySQL display name is the
fail-fast check, since it needs to recognize MySQL specifically (the only
backend with its own named datasource) — and in the normal lowercase config
it's the same string anyway.
--
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]