From b3fcfd33deea109e632372481b69b66023d198eb Mon Sep 17 00:00:00 2001 From: Eduard Tudenhoefner Date: Thu, 11 May 2023 10:38:14 +0200 Subject: [PATCH] use metadata changes instead of updated table metadata --- .../java/org/apache/iceberg/catalog/TableCommit.java | 4 +++- .../org/apache/iceberg/rest/RESTSessionCatalog.java | 2 +- .../java/org/apache/iceberg/rest/TestRESTCatalog.java | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/apache/iceberg/catalog/TableCommit.java b/core/src/main/java/org/apache/iceberg/catalog/TableCommit.java index 372b0a3ecaac..f4255796b990 100644 --- a/core/src/main/java/org/apache/iceberg/catalog/TableCommit.java +++ b/core/src/main/java/org/apache/iceberg/catalog/TableCommit.java @@ -18,6 +18,8 @@ */ package org.apache.iceberg.catalog; +import java.util.List; +import org.apache.iceberg.MetadataUpdate; import org.apache.iceberg.TableMetadata; import org.immutables.value.Value; @@ -27,5 +29,5 @@ public interface TableCommit { TableMetadata base(); - TableMetadata updated(); + List changes(); } 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 c5c3dc3c66ac..7d4a9851074b 100644 --- a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java +++ b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java @@ -884,7 +884,7 @@ public void commitTransaction(SessionContext context, List commits) for (TableCommit commit : commits) { UpdateTableRequest.Builder updateTableBuilder = UpdateTableRequest.builderFor(commit.base()); - commit.updated().changes().forEach(updateTableBuilder::update); + commit.changes().forEach(updateTableBuilder::update); UpdateTableRequest updateTableRequest = updateTableBuilder.build(); ImmutableCommitTableRequest commitTableRequest = diff --git a/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java b/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java index bbdfc3d8b07b..ad9f7c3dee4f 100644 --- a/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java +++ b/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java @@ -1775,7 +1775,7 @@ public void multipleDiffsAgainstSingleTable() { ImmutableTableCommit.builder() .identifier(identifier) .base(((BaseTransaction) transaction).startMetadata()) - .updated(((BaseTransaction) transaction).currentMetadata()) + .changes(((BaseTransaction) transaction).currentMetadata().changes()) .build(); restCatalog.commitTransaction(ImmutableList.of(tableCommit)); @@ -1808,14 +1808,14 @@ public void multipleDiffsAgainstMultipleTables() { ImmutableTableCommit.builder() .identifier(identifier1) .base(((BaseTransaction) transaction1).startMetadata()) - .updated(((BaseTransaction) transaction1).currentMetadata()) + .changes(((BaseTransaction) transaction1).currentMetadata().changes()) .build(); TableCommit tableCommit2 = ImmutableTableCommit.builder() .identifier(identifier2) .base(((BaseTransaction) transaction2).startMetadata()) - .updated(((BaseTransaction) transaction2).currentMetadata()) + .changes(((BaseTransaction) transaction2).currentMetadata().changes()) .build(); restCatalog.commitTransaction(ImmutableList.of(tableCommit1, tableCommit2)); @@ -1854,14 +1854,14 @@ public void multipleDiffsAgainstMultipleTablesLastFails() { ImmutableTableCommit.builder() .identifier(identifier1) .base(((BaseTransaction) transaction1).startMetadata()) - .updated(((BaseTransaction) transaction1).currentMetadata()) + .changes(((BaseTransaction) transaction1).currentMetadata().changes()) .build(); TableCommit tableCommit2 = ImmutableTableCommit.builder() .identifier(identifier2) .base(((BaseTransaction) transaction2).startMetadata()) - .updated(((BaseTransaction) transaction2).currentMetadata()) + .changes(((BaseTransaction) transaction2).currentMetadata().changes()) .build(); assertThatThrownBy(