poojanilangekar commented on code in PR #2301: URL: https://github.com/apache/polaris/pull/2301#discussion_r2271257215
########## runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java: ########## @@ -220,42 +218,18 @@ protected void initializeCatalog() { ConnectionType connectionType = ConnectionType.fromCode(connectionConfigInfoDpo.getConnectionTypeCode()); - switch (connectionType) { - case ICEBERG_REST: - SessionCatalog.SessionContext context = SessionCatalog.SessionContext.createEmpty(); - federatedCatalog = - new RESTCatalog( - context, - (config) -> - HTTPClient.builder(config) - .uri(config.get(org.apache.iceberg.CatalogProperties.URI)) - .build()); - federatedCatalog.initialize( - ((IcebergRestConnectionConfigInfoDpo) connectionConfigInfoDpo).getRemoteCatalogName(), - connectionConfigInfoDpo.asIcebergCatalogProperties(getUserSecretsManager())); - break; - case HADOOP: - // Currently, Polaris supports Hadoop federation only via IMPLICIT authentication. - // Hence, prior to initializing the configuration, ensure that the catalog uses - // IMPLICIT authentication. - AuthenticationParametersDpo authenticationParametersDpo = - connectionConfigInfoDpo.getAuthenticationParameters(); - if (authenticationParametersDpo.getAuthenticationTypeCode() - != AuthenticationType.IMPLICIT.getCode()) { - throw new IllegalStateException( - "Hadoop federation only supports IMPLICIT authentication."); - } - Configuration conf = new Configuration(); - String warehouse = - ((HadoopConnectionConfigInfoDpo) connectionConfigInfoDpo).getWarehouse(); - federatedCatalog = new HadoopCatalog(conf, warehouse); - federatedCatalog.initialize( - warehouse, - connectionConfigInfoDpo.asIcebergCatalogProperties(getUserSecretsManager())); - break; - default: - throw new UnsupportedOperationException( - "Connection type not supported: " + connectionType); + // Use the unified factory pattern for all external catalog types + Instance<ExternalCatalogFactory> externalCatalogFactory = + externalCatalogFactories.select( + Identifier.Literal.of(connectionType.getFactoryIdentifier())); + if (!externalCatalogFactory.isUnsatisfied()) { Review Comment: Done, I've used `isResolvable()` instead. -- 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: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org