adam-christian-software commented on code in PR #3188: URL: https://github.com/apache/polaris/pull/3188#discussion_r2593942719
########## plugins/spark/v4.0/spark/src/main/java/org/apache/polaris/spark/PolarisSparkCatalog.java: ########## @@ -0,0 +1,154 @@ +/* + * 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 java.util.Map; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.exceptions.AlreadyExistsException; +import org.apache.iceberg.spark.Spark3Util; +// Use the spec class defined at client side under the rest package. +// The spec classes used at client side and server side are different in +// terms of import, where the client side uses the shaded jackson library +// from iceberg-spark-runtime. +import org.apache.polaris.spark.rest.GenericTable; +import org.apache.polaris.spark.utils.PolarisCatalogUtils; +import org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException; +import org.apache.spark.sql.catalyst.analysis.NoSuchTableException; +import org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException; +import org.apache.spark.sql.connector.catalog.Identifier; +import org.apache.spark.sql.connector.catalog.Table; +import org.apache.spark.sql.connector.catalog.TableCatalog; +import org.apache.spark.sql.connector.catalog.TableChange; +import org.apache.spark.sql.connector.expressions.Transform; +import org.apache.spark.sql.types.StructType; +import org.apache.spark.sql.util.CaseInsensitiveStringMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A spark TableCatalog Implementation interacts with Polaris specific APIs only. The APIs it + * interacts with is generic table APIs, and all table operations performed in this class are + * expected to be for non-iceberg tables. + */ +public class PolarisSparkCatalog implements TableCatalog { + private static final Logger LOGGER = LoggerFactory.getLogger(PolarisSparkCatalog.class); + + private PolarisCatalog polarisCatalog = null; + private String catalogName = null; + + public PolarisSparkCatalog(PolarisCatalog polarisCatalog) { + this.polarisCatalog = polarisCatalog; + } + + @Override + public void initialize(String name, CaseInsensitiveStringMap options) { + this.catalogName = name; + } + + @Override + public String name() { + return catalogName; + } + + @Override + public Table loadTable(Identifier identifier) throws NoSuchTableException { + try { + GenericTable genericTable = Review Comment: Personally, I would like to do it post-merge of this PR since we are going to have to integrate the common APIs, but I would be fine delaying this PR by doing another cut of the current client. What would you like to do? -- 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]
