You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/07/31 19:04:51 UTC

[GitHub] [iceberg] rdsr commented on a change in pull request #1243: Hive: Add support for custom catalog to Iceberg StorageHandler (#1155)

rdsr commented on a change in pull request #1243:
URL: https://github.com/apache/iceberg/pull/1243#discussion_r463781404



##########
File path: mr/src/main/java/org/apache/iceberg/mr/Catalogs.java
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.mr;
+
+import java.util.Optional;
+import java.util.Properties;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.common.DynConstructors;
+import org.apache.iceberg.exceptions.NoSuchNamespaceException;
+import org.apache.iceberg.hadoop.HadoopCatalog;
+import org.apache.iceberg.hadoop.HadoopTables;
+import org.apache.iceberg.hive.HiveCatalogs;
+import org.apache.iceberg.relocated.com.google.common.annotations.VisibleForTesting;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+public final class Catalogs {
+
+  private static final String HADOOP = "hadoop";
+  private static final String HIVE = "hive";
+
+  private static final String NAME = "name";
+  private static final String LOCATION = "location";
+
+  private Catalogs() {}
+
+  /**
+   * Load an Iceberg table using the catalog and table identifier (or table path) specified by the configuration.
+   * Catalog resolution happens in this order:
+   * 1. Custom catalog if specified by {@link InputFormatConfig#CATALOG_LOADER_CLASS}
+   * 2. Hadoop or Hive catalog if specified by {@link InputFormatConfig#CATALOG}
+   * 3. Hadoop Tables
+   * @param conf a Hadoop conf
+   * @return an Iceberg table
+   */
+  public static Table loadTable(Configuration conf) {
+    return loadTable(conf, conf.get(InputFormatConfig.TABLE_IDENTIFIER), conf.get(InputFormatConfig.TABLE_LOCATION));

Review comment:
       can't we replace TABLE_LOCATION, TABLE_IDENTIFIER and TABLE_PATH with just TABLE_PATH?
   
   e.g see org.apache.iceberg.spark.source.IcebergSource#findTable




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org