kotwal-itpro commented on code in PR #4123:
URL: https://github.com/apache/iceberg-python/pull/4123#discussion_r4405694775


##########
mkdocs/docs/api.md:
##########
@@ -1408,6 +1408,30 @@ assert tbl.metadata.snapshots[-1].summary["abc"] == "def"
 New snapshot summaries automatically include `engine-name` (`pyiceberg`) and 
`engine-version`
 (the installed PyIceberg version). These values override same-named entries in 
`snapshot_properties`.
 
+## Multi-table commits
+
+With the REST catalog, changes to several tables can be committed atomically: 
either every table
+is updated, or none of them is. Stage the changes in one transaction per 
table, then pass the
+transactions to `commit_transactions`:
+
+```python
+orders_tx = orders.transaction()
+orders_tx.append(new_orders)
+items_tx = items.transaction()
+items_tx.append(new_items)
+
+catalog.commit_transactions(orders_tx, items_tx)

Review Comment:
   Good idea. `with orders.transaction() as tx:` can't be used here as it is, 
since leaving that block commits the table on its own. So I added 
`Catalog.transaction()`, which commits every table in one `commit_transactions` 
call when the block exits, and nothing if it raises:
   
   ```python
   with catalog.transaction() as tx:
       tx.table(orders).append(new_orders)
       tx.table(items).append(new_items)
   ```
   
   The docs now lead with this and keep `commit_transactions(...)` as the 
explicit form. It's in 6a294523, with unit tests for the commit on exit, no 
commit on an exception, and a table from another catalog, plus an integration 
test. Happy to rename it (`multi_table_transaction()`?) or drop it if you'd 
rather keep this PR to the explicit call.



-- 
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]

Reply via email to