Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
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);
}
}
12 changes: 10 additions & 2 deletions core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
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;
Expand Down Expand Up @@ -717,8 +718,15 @@ public Transaction createTransaction() {

@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);
Expand Down