Skip to content

Commit 1b93169

Browse files
Fix Hadoop federation to initialize the configuration prior to catalog initialization (#2282)
This PR addresses the gap in Hadoop federation to ensure that we initialize the hadoop configuration prior to initializing the catalog object. The iceberg library expects the hadoop configuration to be initialized before creating a HadoopCatalog object. This change ensures that Polaris is compatible with the underlying iceberg library. Additionally, since the config initialization is based on the underlying (default) core-site.xml file, the change ensures that the federated catalog was created using `IMPLICIT` authentication mode. Testing: Due to current limitations in the current test setup, tested the change manually. [TODO] Add a regtest with hadoop federation once the change is baked into the apache/polaris docker image.
1 parent cfff798 commit 1b93169

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.Optional;
3434
import java.util.Set;
3535
import java.util.stream.Collectors;
36+
import org.apache.hadoop.conf.Configuration;
3637
import org.apache.iceberg.BaseMetadataTable;
3738
import org.apache.iceberg.BaseTable;
3839
import org.apache.iceberg.MetadataUpdate;
@@ -76,6 +77,8 @@
7677
import org.apache.polaris.core.auth.PolarisAuthorizableOperation;
7778
import org.apache.polaris.core.auth.PolarisAuthorizer;
7879
import org.apache.polaris.core.config.FeatureConfiguration;
80+
import org.apache.polaris.core.connection.AuthenticationParametersDpo;
81+
import org.apache.polaris.core.connection.AuthenticationType;
7982
import org.apache.polaris.core.connection.ConnectionConfigInfoDpo;
8083
import org.apache.polaris.core.connection.ConnectionType;
8184
import org.apache.polaris.core.connection.hadoop.HadoopConnectionConfigInfoDpo;
@@ -232,9 +235,22 @@ protected void initializeCatalog() {
232235
connectionConfigInfoDpo.asIcebergCatalogProperties(getUserSecretsManager()));
233236
break;
234237
case HADOOP:
235-
federatedCatalog = new HadoopCatalog();
238+
// Currently, Polaris supports Hadoop federation only via IMPLICIT authentication.
239+
// Hence, prior to initializing the configuration, ensure that the catalog uses
240+
// IMPLICIT authentication.
241+
AuthenticationParametersDpo authenticationParametersDpo =
242+
connectionConfigInfoDpo.getAuthenticationParameters();
243+
if (authenticationParametersDpo.getAuthenticationTypeCode()
244+
!= AuthenticationType.IMPLICIT.getCode()) {
245+
throw new IllegalStateException(
246+
"Hadoop federation only supports IMPLICIT authentication.");
247+
}
248+
Configuration conf = new Configuration();
249+
String warehouse =
250+
((HadoopConnectionConfigInfoDpo) connectionConfigInfoDpo).getWarehouse();
251+
federatedCatalog = new HadoopCatalog(conf, warehouse);
236252
federatedCatalog.initialize(
237-
((HadoopConnectionConfigInfoDpo) connectionConfigInfoDpo).getWarehouse(),
253+
warehouse,
238254
connectionConfigInfoDpo.asIcebergCatalogProperties(getUserSecretsManager()));
239255
break;
240256
default:

0 commit comments

Comments
 (0)