Y-Wakuta commented on code in PR #4281:
URL: https://github.com/apache/polaris/pull/4281#discussion_r3360315989
##########
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));
+ if (!mysqlDataSource.isResolvable()) {
+ throw new IllegalStateException(
Review Comment:
Good point — done. This is part of the same block I added after your last
review (per the Copilot fail-fast comment, as noted on the other thread). The
fail-fast now lives in the orElseGet fallback (your line 131) instead of a
separate up-front block, so a single chain handles the unresolvable case: throw
for MySQL, fall back to the default otherwise.
--
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]