gh-yzou commented on code in PR #1303: URL: https://github.com/apache/polaris/pull/1303#discussion_r2029674807
########## plugins/spark/v3.5/src/main/java/org/apache/polaris/spark/PolarisRESTCatalog.java: ########## @@ -0,0 +1,176 @@ +/* + * 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.spark; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import java.io.Closeable; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.iceberg.CatalogProperties; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.io.CloseableGroup; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.rest.*; +import org.apache.iceberg.rest.auth.OAuth2Util; +import org.apache.iceberg.rest.responses.ConfigResponse; +import org.apache.iceberg.util.EnvironmentUtil; +import org.apache.iceberg.util.PropertyUtil; +import org.apache.polaris.core.rest.PolarisEndpoints; +import org.apache.polaris.core.rest.PolarisResourcePaths; +import org.apache.polaris.service.types.GenericTable; +import org.apache.polaris.spark.rest.CreateGenericTableRESTRequest; +import org.apache.polaris.spark.rest.LoadGenericTableRESTResponse; +import org.apache.polaris.spark.utils.PolarisCatalogUtils; + +public class PolarisRESTCatalog implements PolarisCatalog, Closeable { + public static final String REST_PAGE_SIZE = "rest-page-size"; + + private RESTClient restClient = null; + private CloseableGroup closeables = null; + private Set<Endpoint> endpoints; + private OAuth2Util.AuthSession catalogAuth = null; + private PolarisResourcePaths paths = null; + private Integer pageSize = null; + + // the default endpoints to config if server doesn't specify the 'endpoints' configuration. + private static final Set<Endpoint> DEFAULT_ENDPOINTS = PolarisEndpoints.GENERIC_TABLE_ENDPOINTS; + + public void initialize(Map<String, String> unresolved, OAuth2Util.AuthSession catalogAuth) { + Preconditions.checkArgument(unresolved != null, "Invalid configuration: null"); + + // resolve any configuration that is supplied by environment variables + Map<String, String> props = EnvironmentUtil.resolveAll(unresolved); + + // TODO: switch to use authManager once iceberg dependency is updated to 1.9.0 + this.catalogAuth = catalogAuth; + + this.restClient = Review Comment: updated to ``` try (RESTClient initClient = clientBuilder.apply(props).withAuthSession(catalogAuth)) { config = fetchConfig(initClient, catalogAuth.headers(), props); } catch (IOException e) { throw new UncheckedIOException("Failed to close HTTP client", e); } ``` -- 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]
