rdblue commented on code in PR #7569:
URL: https://github.com/apache/iceberg/pull/7569#discussion_r1199833944
##########
core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java:
##########
@@ -361,4 +364,37 @@ private static TableMetadata commit(TableOperations ops,
UpdateTableRequest requ
return ops.current();
}
+
+ /**
+ * This is a very simplistic approach that only validates the requirements
for each table and does
+ * not do any other conflict detection. Therefore, it does not guarantee
true transactional
+ * atomicity, which is left to the implementation details of a REST server.
+ */
+ public static void commitTransaction(Catalog catalog,
CommitTransactionRequest request) {
+ List<Transaction> transactions = Lists.newArrayList();
+
+ for (CommitTransactionRequest.CommitTableRequest tableChange :
request.tableChanges()) {
+ Table table = catalog.loadTable(tableChange.identifier());
+ if (table instanceof BaseTable) {
+ UpdateTableRequest updateTableRequest =
+ new UpdateTableRequest(tableChange.requirements(),
tableChange.updates());
+
+ Transaction transaction =
+ Transactions.newTransaction(
+ tableChange.identifier().toString(), ((BaseTable)
table).operations());
+ transactions.add(transaction);
+
+ BaseTransaction.TransactionTable txTable =
+ (BaseTransaction.TransactionTable) transaction.table();
+
+ // this performs validations and makes temporary commits that are
in-memory
+ commit(txTable.operations(), updateTableRequest);
Review Comment:
I can see why you'd want to use a transaction to get the bulk of the work
done before committing, but I don't think this actually works because you're
committing the transactions sequentially below.
I think to test we need to pass the `commitTransaction` call through and
implement it either for an `InMemoryCatalog` or JDBC.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]