rdblue commented on a change in pull request #1145: URL: https://github.com/apache/iceberg/pull/1145#discussion_r449708127
########## File path: flink/src/main/java/org/apache/iceberg/flink/TableUtil.java ########## @@ -0,0 +1,44 @@ +/* + * 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.iceberg.flink; + +import org.apache.hadoop.conf.Configuration; +import org.apache.iceberg.Table; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.hadoop.HadoopTables; +import org.apache.iceberg.hive.HiveCatalog; +import org.apache.iceberg.hive.HiveCatalogs; + +class TableUtil { + + private TableUtil() { + } + + static Table findTable(String path, Configuration conf) { Review comment: I don't think it is a good idea to mimic the behavior of Spark 2 here. That's really limited. What about using job configuration to instantiate a catalog and load a table by name, like the newer Spark 3 integration does? Here's the javadoc: https://github.com/apache/iceberg/blob/master/spark3/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L64-L77 That uses this logic to determine the catalog and load a table: ```java /** * Build an Iceberg {@link Catalog} to be used by this Spark catalog adapter. * * @param name Spark's catalog name * @param options Spark's catalog options * @return an Iceberg catalog */ protected Catalog buildIcebergCatalog(String name, CaseInsensitiveStringMap options) { Configuration conf = SparkSession.active().sparkContext().hadoopConfiguration(); String catalogType = options.getOrDefault("type", "hive"); switch (catalogType) { case "hive": int clientPoolSize = options.getInt("clients", 2); String uri = options.get("uri"); return new HiveCatalog(name, uri, clientPoolSize, conf); case "hadoop": String warehouseLocation = options.get("warehouse"); return new HadoopCatalog(name, conf, warehouseLocation); default: throw new UnsupportedOperationException("Unknown catalog type: " + catalogType); } } ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
