kevinjqliu commented on code in PR #2871:
URL: https://github.com/apache/iceberg-python/pull/2871#discussion_r2669615686


##########
pyiceberg/table/__init__.py:
##########
@@ -275,8 +275,20 @@ def __exit__(self, exctype: type[BaseException] | None, 
excinst: BaseException |
         if exctype is None and excinst is None and exctb is None:
             self.commit_transaction()
 
-    def _apply(self, updates: tuple[TableUpdate, ...], requirements: 
tuple[TableRequirement, ...] = ()) -> Transaction:
-        """Check if the requirements are met, and applies the updates to the 
metadata."""
+    def _stage(

Review Comment:
   Thanks for adding this! This is a clean and explicit api surface 😄 . We dont 
need to worry about the state of `_autocommit` 
   
   cc @Fokko WDYT about adding this helper method to the base Transaction 
class? 



##########
pyiceberg/table/update/snapshot.py:
##########
@@ -941,6 +948,43 @@ def remove_branch(self, branch_name: str) -> 
ManageSnapshots:
         """
         return self._remove_ref_snapshot(ref_name=branch_name)
 
+    def set_current_snapshot(self, snapshot_id: int | None = None, ref_name: 
str | None = None) -> ManageSnapshots:
+        """Set the current snapshot to a specific snapshot ID or ref.
+
+        Args:
+            snapshot_id: The ID of the snapshot to set as current.
+            ref_name: The snapshot reference (branch or tag) to set as current.
+
+        Returns:
+            This for method chaining.
+
+        Raises:
+            ValueError: If neither or both arguments are provided, or if the 
snapshot/ref does not exist.
+        """
+        self._commit_if_ref_updates_exist()

Review Comment:
   awesome! this follows the [java 
SnapshotManager](https://github.com/apache/iceberg/blob/bc7bfa5de4743853d9647ad095322ba71e304221/core/src/main/java/org/apache/iceberg/SnapshotManager.java#L52-L57)
 implementation and allows creating a tag and set the current snapshot as the 
tag in the same catalog commit (i.e. in the same transaction)
   



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