@@ -2015,7 +2015,15 @@ def create_branch(
20152015 return self
20162016
20172017 def rollback_to_snapshot (self , snapshot_id : int ) -> ManageSnapshots :
2018- """Rollback the table to the given snapshot id, whose snapshot needs to be an ancestor of the current table state."""
2018+ """Rollback the table to the given snapshot id.
2019+
2020+ The snapshot needs to be an ancestor of the current table state.
2021+
2022+ Args:
2023+ snapshot_id (int): rollback to this snapshot_id that used to be current.
2024+ Returns:
2025+ This for method chaining
2026+ """
20192027 self ._commit_if_ref_updates_exist ()
20202028 if self ._transaction ._table .snapshot_by_id (snapshot_id ) is None :
20212029 raise ValidationError (f"Cannot roll back to unknown snapshot id: { snapshot_id } " )
@@ -2028,7 +2036,15 @@ def rollback_to_snapshot(self, snapshot_id: int) -> ManageSnapshots:
20282036 return self
20292037
20302038 def rollback_to_timestamp (self , timestamp : int ) -> ManageSnapshots :
2031- """Rollback the table to the snapshot right before the given timestamp."""
2039+ """Rollback the table to the snapshot right before the given timestamp.
2040+
2041+ The snapshot needs to be an ancestor of the current table state.
2042+
2043+ Args:
2044+ timestamp (int): rollback to the snapshot that used to be current right before this timestamp.
2045+ Returns:
2046+ This for method chaining
2047+ """
20322048 self ._commit_if_ref_updates_exist ()
20332049 if (snapshot := self ._transaction ._table .snapshot_as_of_timestamp (timestamp , inclusive = False )) is None :
20342050 raise ValidationError (f"Cannot roll back, no valid snapshot older than: { timestamp } " )
@@ -2041,7 +2057,16 @@ def rollback_to_timestamp(self, timestamp: int) -> ManageSnapshots:
20412057 return self
20422058
20432059 def set_current_snapshot (self , snapshot_id : Optional [int ] = None , ref_name : Optional [str ] = None ) -> ManageSnapshots :
2044- """Set the table to a specific snapshot identified either by its id or the branch/tag its on, not both."""
2060+ """Set the table to a specific snapshot identified either by its id or the branch/tag its on, not both.
2061+
2062+ The snapshot is not required to be an ancestor of the current table state.
2063+
2064+ Args:
2065+ snapshot_id (Optional[int]): id of the snapshot to be set as current
2066+ ref_name (Optional[str]): branch/tag where the snapshot to be set as current exists.
2067+ Returns:
2068+ This for method chaining
2069+ """
20452070 self ._commit_if_ref_updates_exist ()
20462071 if (not snapshot_id or ref_name ) and (snapshot_id or not ref_name ):
20472072 raise ValidationError ("Either snapshot_id or ref must be provided" )
0 commit comments