From d79e9be544178ae1b05cb45ba495ea175e622b93 Mon Sep 17 00:00:00 2001 From: Slawomir Pajak Date: Wed, 6 Nov 2024 11:46:19 +0100 Subject: [PATCH] Throw TrinoException when Iceberg commit fails --- .../main/java/io/trino/plugin/iceberg/IcebergMetadata.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java index 82e7195acaa85..5841143ad854d 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java @@ -163,6 +163,8 @@ import org.apache.iceberg.UpdateSchema; import org.apache.iceberg.UpdateStatistics; import org.apache.iceberg.exceptions.AlreadyExistsException; +import org.apache.iceberg.exceptions.CommitFailedException; +import org.apache.iceberg.exceptions.CommitStateUnknownException; import org.apache.iceberg.exceptions.ValidationException; import org.apache.iceberg.expressions.Expressions; import org.apache.iceberg.expressions.Term; @@ -1810,7 +1812,7 @@ private static void commitUpdateAndTransaction(SnapshotUpdate update, Connect commit(update, session); commitTransaction(transaction, operation); } - catch (UncheckedIOException | ValidationException e) { + catch (UncheckedIOException | ValidationException | CommitFailedException | CommitStateUnknownException e) { throw new TrinoException(ICEBERG_COMMIT_ERROR, format("Failed to commit during %s: %s", operation, firstNonNull(e.getMessage(), e)), e); } } @@ -1820,7 +1822,7 @@ private static void commitTransaction(Transaction transaction, String operation) try { transaction.commitTransaction(); } - catch (ValidationException e) { + catch (ValidationException | CommitFailedException | CommitStateUnknownException e) { throw new TrinoException(ICEBERG_COMMIT_ERROR, format("Failed to commit the transaction during %s: %s", operation, firstNonNull(e.getMessage(), e)), e); } }