Skip to content

Commit

Permalink
Address review comments and fix issues with Nessie version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
ajantha-bhat committed Jun 14, 2023
1 parent 6578c25 commit 505bd44
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions nessie/src/main/java/org/apache/iceberg/nessie/NessieCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,21 @@ public void initialize(String name, Map<String, String> options) {
createNessieClientBuilder(
options.get(NessieConfigConstants.CONF_NESSIE_CLIENT_BUILDER_IMPL))
.fromConfig(x -> options.get(removePrefix.apply(x)));
final String apiVersion = options.get(NessieUtil.CLIENT_API_VERSION);
// default version is set to v1.
final String apiVersion = options.getOrDefault(NessieUtil.CLIENT_API_VERSION, "1");
NessieApiV1 api;
if (apiVersion == null || apiVersion.equalsIgnoreCase("1")) {
// default version is set to v1.
api = nessieClientBuilder.build(NessieApiV1.class);
} else if (apiVersion.equalsIgnoreCase("2")) {
api = nessieClientBuilder.build(NessieApiV2.class);
} else {
throw new IllegalArgumentException(
String.format(
"Unsupported %s: %s. Can only be 1 or 2", NessieUtil.CLIENT_API_VERSION, apiVersion));
switch (apiVersion) {
case "1":
api = nessieClientBuilder.build(NessieApiV1.class);
break;
case "2":
api = nessieClientBuilder.build(NessieApiV2.class);
break;
default:
throw new IllegalArgumentException(
String.format(
"Unsupported %s: %s. Can only be 1 or 2",
NessieUtil.CLIENT_API_VERSION, apiVersion));
}

initialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class NessieUtil {
public static final String NESSIE_CONFIG_PREFIX = "nessie.";
static final String APPLICATION_TYPE = "application-type";

public static final String CLIENT_API_VERSION = "client-api-version";
public static final String CLIENT_API_VERSION = "nessie.client-api-version";

private NessieUtil() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void testInvalidClientApiVersion() throws IOException {
ImmutableMap.<String, String>builder().put(NessieUtil.CLIENT_API_VERSION, "3");
Assertions.assertThatThrownBy(() -> newCatalog.initialize("nessie", options.buildOrThrow()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Unsupported client-api-version: 3. Can only be 1 or 2");
.hasMessage("Unsupported nessie.client-api-version: 3. Can only be 1 or 2");
}
}
}

0 comments on commit 505bd44

Please sign in to comment.