travis-bowen commented on code in PR #4: URL: https://github.com/apache/polaris-tools/pull/4#discussion_r2045574200
########## polaris-synchronizer/api/src/main/java/org/apache/polaris/tools/sync/polaris/service/IcebergCatalogService.java: ########## @@ -0,0 +1,54 @@ +/* + * 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.tools.sync.polaris.service; + +import org.apache.iceberg.Table; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.catalog.TableIdentifier; + +import java.util.List; +import java.util.Map; + +/** + * Wrapper around {@link org.apache.iceberg.catalog.Catalog} that exposes functionality + * that uses multiple Iceberg operations. For example, cascading drops of namespaces. + */ +public interface IcebergCatalogService { + + // NAMESPACES + List<Namespace> listNamespaces(Namespace parentNamespace); + Map<String, String> loadNamespaceMetadata(Namespace namespace); + void createNamespace(Namespace namespace, Map<String, String> namespaceMetadata); + void setNamespaceProperties(Namespace namespace, Map<String, String> namespaceProperties); + + /** + * Drop a namespace by first dropping all nested namespaces and tables underneath the namespace + * hierarchy. The empty namespace will not be dropped. Review Comment: By 'the empty namespace will not be dropped' might clarify to say 'Namespace.empty()' which represents the root namespace - to clarify that a namespace that is empty isn't the same thing. ########## polaris-synchronizer/cli/src/main/java/org/apache/polaris/tools/sync/polaris/CreateOmnipotentPrincipalCommand.java: ########## @@ -79,8 +93,17 @@ public class CreateOmnipotentPrincipalCommand implements Callable<Integer> { @Override public Integer call() throws Exception { - PolarisService polaris = options.buildService(); - AccessControlService accessControlService = new AccessControlService(polaris); + polarisApiConnectionProperties.putIfAbsent("iceberg-write-access", String.valueOf(withWriteAccess)); + + PolarisService polaris = PolarisServiceFactory.createPolarisService( Review Comment: It feels a little strange to convert withWriteAccess to implicitly imply target or source - it would be kind of nicer if it's possible for the variable to just maintain the withWriteAccess through the object creation, but if there's good reason we can always start with this. ########## polaris-synchronizer/api/src/main/java/org/apache/polaris/tools/sync/polaris/service/IcebergCatalogService.java: ########## @@ -0,0 +1,54 @@ +/* + * 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.tools.sync.polaris.service; + +import org.apache.iceberg.Table; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.catalog.TableIdentifier; + +import java.util.List; +import java.util.Map; + +/** + * Wrapper around {@link org.apache.iceberg.catalog.Catalog} that exposes functionality + * that uses multiple Iceberg operations. For example, cascading drops of namespaces. + */ +public interface IcebergCatalogService { + + // NAMESPACES + List<Namespace> listNamespaces(Namespace parentNamespace); + Map<String, String> loadNamespaceMetadata(Namespace namespace); + void createNamespace(Namespace namespace, Map<String, String> namespaceMetadata); + void setNamespaceProperties(Namespace namespace, Map<String, String> namespaceProperties); + + /** + * Drop a namespace by first dropping all nested namespaces and tables underneath the namespace + * hierarchy. The empty namespace will not be dropped. + * @param namespace the namespace to drop + */ + void dropNamespaceCascade(Namespace namespace); + + // TABLES + List<TableIdentifier> listTables(Namespace namespace); + Table loadTable(TableIdentifier tableIdentifier); + void registerTable(TableIdentifier tableIdentifier, String metadataFileLocation); + void dropTableWithoutPurge(TableIdentifier tableIdentifier); Review Comment: Feels a little strange to have dropTableWithoutPurge when I believe the iceberg apis are just dropCatalog and then you specify whether purge is requested or not. not a blocker though so if it's not a quick method name update feel free to skip. ########## polaris-synchronizer/api/src/main/java/org/apache/polaris/tools/sync/polaris/service/impl/PolarisIcebergCatalogService.java: ########## @@ -0,0 +1,150 @@ +/* + * 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.tools.sync.polaris.service.impl; + +import org.apache.iceberg.CatalogUtil; +import org.apache.iceberg.Table; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.polaris.core.admin.model.PrincipalWithCredentials; +import org.apache.polaris.tools.sync.polaris.catalog.PolarisCatalog; +import org.apache.polaris.tools.sync.polaris.service.IcebergCatalogService; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class PolarisIcebergCatalogService implements IcebergCatalogService { + + private final PolarisCatalog catalog; + + public PolarisIcebergCatalogService(String uri, String catalogName, PrincipalWithCredentials migratorPrincipal) { + Map<String, String> catalogProperties = new HashMap<>(); + catalogProperties.put("uri", uri); + catalogProperties.put("warehouse", catalogName); + + String clientId = migratorPrincipal.getCredentials().getClientId(); + String clientSecret = migratorPrincipal.getCredentials().getClientSecret(); Review Comment: Does this need any other properties provided to the CLI? For example - oauth endpoint if it's not standard? Or other forms of access (like just an auth token - if that's supported) -- 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]
