rdblue commented on a change in pull request #3162:
URL: https://github.com/apache/iceberg/pull/3162#discussion_r714177215



##########
File path: mr/src/main/java/org/apache/iceberg/mr/Catalogs.java
##########
@@ -243,15 +243,21 @@ public static boolean hiveCatalog(Configuration conf, 
Properties props) {
    */
   private static Map<String, String> 
addCatalogPropertiesIfMissing(Configuration conf, String catalogType,
                                                                    Map<String, 
String> catalogProperties) {
-    if (catalogType != null) {
-      catalogProperties.putIfAbsent(CatalogUtil.ICEBERG_CATALOG_TYPE, 
catalogType);
-    }
-
     String legacyCatalogImpl = 
conf.get(InputFormatConfig.CATALOG_LOADER_CLASS);
     if (legacyCatalogImpl != null) {
       catalogProperties.putIfAbsent(CatalogProperties.CATALOG_IMPL, 
legacyCatalogImpl);
     }
 
+    if (catalogProperties.containsKey(CatalogUtil.ICEBERG_CATALOG_TYPE) &&
+            catalogProperties.containsKey(CatalogProperties.CATALOG_IMPL)) {
+      throw new IllegalArgumentException(String.format("Provide only one of 
the following configs: '%s' or '%s'",
+              CatalogUtil.ICEBERG_CATALOG_TYPE, 
CatalogProperties.CATALOG_IMPL));

Review comment:
       This should use a precondition rather than an `if`.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to