rymurr commented on a change in pull request #1875:
URL: https://github.com/apache/iceberg/pull/1875#discussion_r543670169



##########
File path: core/src/main/java/org/apache/iceberg/CatalogUtil.java
##########
@@ -169,6 +174,40 @@ public static Catalog loadCatalog(
     return catalog;
   }
 
+  public static Catalog buildIcebergCatalog(String name, Map<String, String> 
options, Configuration conf) {
+
+    String catalogImpl = options.get(CatalogProperties.CATALOG_IMPL);
+    if (catalogImpl != null) {
+      return CatalogUtil.loadCatalog(catalogImpl, name, options, conf);
+    }
+
+    String catalogType = options.getOrDefault(ICEBERG_CATALOG_TYPE, 
ICEBERG_CATALOG_TYPE_HIVE);
+    switch (catalogType.toLowerCase(Locale.ENGLISH)) {
+      case ICEBERG_CATALOG_TYPE_HIVE:
+        String clientPoolSize = 
options.getOrDefault(CatalogProperties.HIVE_CLIENT_POOL_SIZE,
+            Integer.toString(CatalogProperties.HIVE_CLIENT_POOL_SIZE_DEFAULT));
+        String uri = options.get(CatalogProperties.HIVE_URI);
+        return buildHiveCatalog(name, uri, Integer.parseInt(clientPoolSize), 
conf);
+      case ICEBERG_CATALOG_TYPE_HADOOP:
+        String warehouseLocation = 
options.get(CatalogProperties.WAREHOUSE_LOCATION);
+        return new HadoopCatalog(name, conf, warehouseLocation, options);
+
+      default:
+        throw new UnsupportedOperationException("Unknown catalog type: " + 
catalogType);
+    }
+  }
+
+  private static Catalog buildHiveCatalog(String name, String uri, int 
clientPoolSize, Configuration conf) {

Review comment:
       cool. I have switched both Hive and Hadoop catalogs to use this pattern. 
I left the old constructors and marked Deprecated.




----------------------------------------------------------------
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]

Reply via email to