rdblue commented on a change in pull request #3162:
URL: https://github.com/apache/iceberg/pull/3162#discussion_r726223621
##########
File path: core/src/main/java/org/apache/iceberg/CatalogUtil.java
##########
@@ -208,21 +208,24 @@ public static Catalog loadCatalog(
*/
public static Catalog buildIcebergCatalog(String name, Map<String, String>
options, Configuration conf) {
String catalogImpl = options.get(CatalogProperties.CATALOG_IMPL);
- if (catalogImpl == null) {
- String catalogType = PropertyUtil.propertyAsString(options,
ICEBERG_CATALOG_TYPE, ICEBERG_CATALOG_TYPE_HIVE);
- switch (catalogType.toLowerCase(Locale.ENGLISH)) {
- case ICEBERG_CATALOG_TYPE_HIVE:
- catalogImpl = ICEBERG_CATALOG_HIVE;
- break;
- case ICEBERG_CATALOG_TYPE_HADOOP:
- catalogImpl = ICEBERG_CATALOG_HADOOP;
- break;
- default:
- throw new UnsupportedOperationException("Unknown catalog type: " +
catalogType);
- }
+ if (catalogImpl != null) {
+ Preconditions.checkArgument(!options.containsKey(ICEBERG_CATALOG_TYPE),
+ "Provide only one of the following configs: '%s' or '%s'",
+ ICEBERG_CATALOG_TYPE, CatalogProperties.CATALOG_IMPL);
Review comment:
I think you could do the same thing with a lot fewer changes by adding
this precondition check in an `else` block rather than reversing the logic and
making multiple calls to `loadCatalog`. The nice thing about the previous
implementation was that it had just one return and loaded the catalog the exact
same way for every case.
--
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]