joyhaldar commented on code in PR #4050: URL: https://github.com/apache/polaris/pull/4050#discussion_r2992573311
########## extensions/federation/bigquery/src/main/java/org/apache/polaris/extensions/federation/bigquery/BigQueryMetastoreFederatedCatalogFactory.java: ########## @@ -0,0 +1,81 @@ +/* + * 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.extensions.federation.bigquery; + +import io.smallrye.common.annotation.Identifier; +import jakarta.enterprise.context.ApplicationScoped; +import java.util.Map; +import org.apache.iceberg.catalog.Catalog; +import org.apache.iceberg.gcp.bigquery.BigQueryMetastoreCatalog; +import org.apache.iceberg.rest.RESTUtil; +import org.apache.polaris.core.catalog.ExternalCatalogFactory; +import org.apache.polaris.core.catalog.GenericTableCatalog; +import org.apache.polaris.core.connection.AuthenticationParametersDpo; +import org.apache.polaris.core.connection.AuthenticationType; +import org.apache.polaris.core.connection.ConnectionConfigInfoDpo; +import org.apache.polaris.core.connection.ConnectionType; +import org.apache.polaris.core.connection.bigquery.BigQueryMetastoreConnectionConfigInfoDpo; +import org.apache.polaris.core.credentials.PolarisCredentialManager; + +/** + * Factory class for creating a BigQuery Metastore catalog handle based on connection configuration. + */ +@ApplicationScoped +@Identifier(ConnectionType.BIGQUERY_FACTORY_IDENTIFIER) +public class BigQueryMetastoreFederatedCatalogFactory implements ExternalCatalogFactory { + + @Override + public Catalog createCatalog( + ConnectionConfigInfoDpo connectionConfigInfoDpo, + PolarisCredentialManager polarisCredentialManager, + Map<String, String> catalogProperties) { + + // Currently, Polaris supports BigQuery Metastore 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() Review Comment: Thank you for your review JB. I copied this pattern from [HiveFederatedCatalogFactory](https://github.com/apache/polaris/blob/49766cca72e6a21ce21cc002a571d485a4586f44/extensions/federation/hive/src/main/java/org/apache/polaris/extensions/federation/hive/HiveFederatedCatalogFactory.java#L49) and [HadoopFederatedCatalogFactory](https://github.com/apache/polaris/blob/49766cca72e6a21ce21cc002a571d485a4586f44/extensions/federation/hadoop/src/main/java/org/apache/polaris/extensions/federation/hadoop/HadoopFederatedCatalogFactory.java#L50) which also don't have null checks. Should I add the null check here and open a separate PR to fix Hive and Hadoop as well? Or keep it consistent with existing code for now? -- 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]
