This is an automated email from the ASF dual-hosted git repository.
kevinjqliu 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 3694095292 Throw CommitFailedException when BQ returns
FAILED_PRECONDITION. (#14801)
3694095292 is described below
commit 36940952929af15fc204cc8548d374932cbc70a0
Author: Vladislav Sidorovich <[email protected]>
AuthorDate: Thu Dec 11 00:42:18 2025 +0100
Throw CommitFailedException when BQ returns FAILED_PRECONDITION. (#14801)
---
.../iceberg/gcp/bigquery/BigQueryMetastoreClientImpl.java | 4 ++--
.../apache/iceberg/gcp/bigquery/BigQueryTableOperations.java | 12 +-----------
.../iceberg/gcp/bigquery/TestBigQueryTableOperations.java | 5 ++---
3 files changed, 5 insertions(+), 16 deletions(-)
diff --git
a/bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryMetastoreClientImpl.java
b/bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryMetastoreClientImpl.java
index 9af9844d84..f61c37fb08 100644
---
a/bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryMetastoreClientImpl.java
+++
b/bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryMetastoreClientImpl.java
@@ -61,6 +61,7 @@ import java.util.stream.Stream;
import org.apache.iceberg.BaseMetastoreTableOperations;
import org.apache.iceberg.exceptions.AlreadyExistsException;
import org.apache.iceberg.exceptions.BadRequestException;
+import org.apache.iceberg.exceptions.CommitFailedException;
import org.apache.iceberg.exceptions.ForbiddenException;
import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
import org.apache.iceberg.exceptions.NoSuchIcebergTableException;
@@ -70,7 +71,6 @@ import org.apache.iceberg.exceptions.NotAuthorizedException;
import org.apache.iceberg.exceptions.RuntimeIOException;
import org.apache.iceberg.exceptions.ServiceFailureException;
import org.apache.iceberg.exceptions.ServiceUnavailableException;
-import org.apache.iceberg.exceptions.ValidationException;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
@@ -650,7 +650,7 @@ public final class BigQueryMetastoreClientImpl implements
BigQueryMetastoreClien
case HttpStatusCodes.STATUS_CODE_FORBIDDEN:
throw new ForbiddenException("%s", errorMessage);
case HttpStatusCodes.STATUS_CODE_PRECONDITION_FAILED:
- throw new ValidationException("%s", errorMessage);
+ throw new CommitFailedException("%s", errorMessage);
case HttpStatusCodes.STATUS_CODE_NOT_FOUND:
throw new IllegalArgumentException(errorMessage);
case HttpStatusCodes.STATUS_CODE_SERVER_ERROR:
diff --git
a/bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryTableOperations.java
b/bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryTableOperations.java
index d57aab5053..e5f0a44957 100644
---
a/bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryTableOperations.java
+++
b/bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryTableOperations.java
@@ -21,7 +21,6 @@ package org.apache.iceberg.gcp.bigquery;
import com.google.api.services.bigquery.model.ExternalCatalogTableOptions;
import com.google.api.services.bigquery.model.Table;
import com.google.api.services.bigquery.model.TableReference;
-import java.util.Locale;
import java.util.Map;
import org.apache.iceberg.BaseMetastoreOperations;
import org.apache.iceberg.BaseMetastoreTableOperations;
@@ -178,16 +177,7 @@ final class BigQueryTableOperations extends
BaseMetastoreTableOperations {
}
options.setParameters(buildTableParameters(newMetadataLocation, metadata));
- try {
- client.update(tableReference, table);
- } catch (ValidationException e) {
- if (e.getMessage().toLowerCase(Locale.ENGLISH).contains("etag
mismatch")) {
- throw new CommitFailedException(
- "Updating table failed due to conflict updates (etag mismatch).
Retry the update");
- }
-
- throw e;
- }
+ client.update(tableReference, table);
}
// To make the table queryable from Hive, the user would likely be setting
the HIVE_ENGINE_ENABLED
diff --git
a/bigquery/src/test/java/org/apache/iceberg/gcp/bigquery/TestBigQueryTableOperations.java
b/bigquery/src/test/java/org/apache/iceberg/gcp/bigquery/TestBigQueryTableOperations.java
index 9b8b90e1f8..3404106882 100644
---
a/bigquery/src/test/java/org/apache/iceberg/gcp/bigquery/TestBigQueryTableOperations.java
+++
b/bigquery/src/test/java/org/apache/iceberg/gcp/bigquery/TestBigQueryTableOperations.java
@@ -177,12 +177,11 @@ public class TestBigQueryTableOperations {
org.apache.iceberg.Table loadedTable = catalog.loadTable(IDENTIFIER);
when(client.update(any(), any()))
- .thenThrow(new ValidationException("error message etag mismatch"));
+ .thenThrow(new CommitFailedException("error message etag mismatch"));
assertThatThrownBy(
() -> loadedTable.updateSchema().addColumn("n",
Types.IntegerType.get()).commit())
.isInstanceOf(CommitFailedException.class)
- .hasMessageContaining(
- "Updating table failed due to conflict updates (etag mismatch).
Retry the update");
+ .hasMessage("error message etag mismatch");
}
@Test