This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new 5b84f34a53 Core: Don't fail if a REST service doesn't support views
(#9754)
5b84f34a53 is described below
commit 5b84f34a5386fc61b17bfe7dc7c1cbe565550958
Author: Eduard Tudenhoefner <[email protected]>
AuthorDate: Tue Feb 20 00:14:52 2024 +0100
Core: Don't fail if a REST service doesn't support views (#9754)
---
.../org/apache/iceberg/exceptions/BadRequestException.java | 6 +++---
.../org/apache/iceberg/exceptions/ForbiddenException.java | 6 +++---
.../java/org/apache/iceberg/rest/RESTSessionCatalog.java | 12 ++++++++++--
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git
a/api/src/main/java/org/apache/iceberg/exceptions/BadRequestException.java
b/api/src/main/java/org/apache/iceberg/exceptions/BadRequestException.java
index c699c1ab22..4518cea8f5 100644
--- a/api/src/main/java/org/apache/iceberg/exceptions/BadRequestException.java
+++ b/api/src/main/java/org/apache/iceberg/exceptions/BadRequestException.java
@@ -21,14 +21,14 @@ package org.apache.iceberg.exceptions;
import com.google.errorprone.annotations.FormatMethod;
/** Exception thrown on HTTP 400 - Bad Request */
-public class BadRequestException extends RuntimeException implements
CleanableFailure {
+public class BadRequestException extends RESTException implements
CleanableFailure {
@FormatMethod
public BadRequestException(String message, Object... args) {
- super(String.format(message, args));
+ super(message, args);
}
@FormatMethod
public BadRequestException(Throwable cause, String message, Object... args) {
- super(String.format(message, args), cause);
+ super(cause, message, args);
}
}
diff --git
a/api/src/main/java/org/apache/iceberg/exceptions/ForbiddenException.java
b/api/src/main/java/org/apache/iceberg/exceptions/ForbiddenException.java
index f66b417fa7..e80cb800d0 100644
--- a/api/src/main/java/org/apache/iceberg/exceptions/ForbiddenException.java
+++ b/api/src/main/java/org/apache/iceberg/exceptions/ForbiddenException.java
@@ -21,14 +21,14 @@ package org.apache.iceberg.exceptions;
import com.google.errorprone.annotations.FormatMethod;
/** Exception thrown on HTTP 403 Forbidden - Failed authorization checks. */
-public class ForbiddenException extends RuntimeException implements
CleanableFailure {
+public class ForbiddenException extends RESTException implements
CleanableFailure {
@FormatMethod
public ForbiddenException(String message, Object... args) {
- super(String.format(message, args));
+ super(message, args);
}
@FormatMethod
public ForbiddenException(Throwable cause, String message, Object... args) {
- super(String.format(message, args), cause);
+ super(cause, message, args);
}
}
diff --git a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
index 87519cfd9d..742caa9494 100644
--- a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
+++ b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
@@ -59,6 +59,7 @@ import org.apache.iceberg.exceptions.AlreadyExistsException;
import org.apache.iceberg.exceptions.NoSuchNamespaceException;
import org.apache.iceberg.exceptions.NoSuchTableException;
import org.apache.iceberg.exceptions.NoSuchViewException;
+import org.apache.iceberg.exceptions.RESTException;
import org.apache.iceberg.hadoop.Configurable;
import org.apache.iceberg.io.CloseableGroup;
import org.apache.iceberg.io.FileIO;
@@ -717,8 +718,15 @@ public class RESTSessionCatalog extends
BaseViewSessionCatalog
@Override
public Transaction replaceTransaction() {
- if (viewExists(context, ident)) {
- throw new AlreadyExistsException("View with same name already exists:
%s", ident);
+ try {
+ if (viewExists(context, ident)) {
+ throw new AlreadyExistsException("View with same name already
exists: %s", ident);
+ }
+ } catch (RESTException | UnsupportedOperationException e) {
+ // don't fail if the server doesn't support views, which could be due
to:
+ // 1. server or backing catalog doesn't support views
+ // 2. newer client talks to an older server that doesn't support views
+ LOG.debug("Failed to check whether view {} exists", ident, e);
}
LoadTableResponse response = loadInternal(context, ident, snapshotMode);