Skip to content

Commit

Permalink
Nessie: change commit operation type (apache#2411)
Browse files Browse the repository at this point in the history
This minor fix changes how the Nessie Table ops commits a table.
Instead of using the single table commit endpoint,
it will now use the multi-table endpoint. This is more
stable long-term as the single table commit may be deprecated
  • Loading branch information
rymurr authored Apr 11, 2021
1 parent b102843 commit 23edff7
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import org.projectnessie.model.ContentsKey;
import org.projectnessie.model.IcebergTable;
import org.projectnessie.model.ImmutableIcebergTable;
import org.projectnessie.model.ImmutableOperations;
import org.projectnessie.model.Operation;
import org.projectnessie.model.Operations;

/**
* Nessie implementation of Iceberg TableOperations.
Expand Down Expand Up @@ -91,11 +94,10 @@ protected void doCommit(TableMetadata base, TableMetadata metadata) {
boolean threw = true;
try {
IcebergTable newTable = ImmutableIcebergTable.builder().metadataLocation(newMetadataLocation).build();
client.getContentsApi().setContents(key,
reference.getAsBranch().getName(),
reference.getHash(),
String.format("iceberg commit%s", applicationId()),
newTable);
Operations op = ImmutableOperations.builder().addOperations(Operation.Put.of(key, newTable)).build();
client.getTreeApi().commitMultipleOperations(reference.getAsBranch().getName(), reference.getHash(),
String.format("iceberg commit%s", applicationId()), op);

threw = false;
} catch (NessieConflictException ex) {
throw new CommitFailedException(ex, "Commit failed: Reference hash is out of date. " +
Expand Down

0 comments on commit 23edff7

Please sign in to comment.