@@ -2033,7 +2033,15 @@ def create_branch(
2033
2033
return self
2034
2034
2035
2035
def rollback_to_snapshot (self , snapshot_id : int ) -> ManageSnapshots :
2036
- """Rollback the table to the given snapshot id, whose snapshot needs to be an ancestor of the current table state."""
2036
+ """Rollback the table to the given snapshot id.
2037
+
2038
+ The snapshot needs to be an ancestor of the current table state.
2039
+
2040
+ Args:
2041
+ snapshot_id (int): rollback to this snapshot_id that used to be current.
2042
+ Returns:
2043
+ This for method chaining
2044
+ """
2037
2045
self ._commit_if_ref_updates_exist ()
2038
2046
if self ._transaction ._table .snapshot_by_id (snapshot_id ) is None :
2039
2047
raise ValidationError (f"Cannot roll back to unknown snapshot id: { snapshot_id } " )
@@ -2046,7 +2054,15 @@ def rollback_to_snapshot(self, snapshot_id: int) -> ManageSnapshots:
2046
2054
return self
2047
2055
2048
2056
def rollback_to_timestamp (self , timestamp : int ) -> ManageSnapshots :
2049
- """Rollback the table to the snapshot right before the given timestamp."""
2057
+ """Rollback the table to the snapshot right before the given timestamp.
2058
+
2059
+ The snapshot needs to be an ancestor of the current table state.
2060
+
2061
+ Args:
2062
+ timestamp (int): rollback to the snapshot that used to be current right before this timestamp.
2063
+ Returns:
2064
+ This for method chaining
2065
+ """
2050
2066
self ._commit_if_ref_updates_exist ()
2051
2067
if (snapshot := self ._transaction ._table .snapshot_as_of_timestamp (timestamp , inclusive = False )) is None :
2052
2068
raise ValidationError (f"Cannot roll back, no valid snapshot older than: { timestamp } " )
@@ -2059,7 +2075,16 @@ def rollback_to_timestamp(self, timestamp: int) -> ManageSnapshots:
2059
2075
return self
2060
2076
2061
2077
def set_current_snapshot (self , snapshot_id : Optional [int ] = None , ref_name : Optional [str ] = None ) -> ManageSnapshots :
2062
- """Set the table to a specific snapshot identified either by its id or the branch/tag its on, not both."""
2078
+ """Set the table to a specific snapshot identified either by its id or the branch/tag its on, not both.
2079
+
2080
+ The snapshot is not required to be an ancestor of the current table state.
2081
+
2082
+ Args:
2083
+ snapshot_id (Optional[int]): id of the snapshot to be set as current
2084
+ ref_name (Optional[str]): branch/tag where the snapshot to be set as current exists.
2085
+ Returns:
2086
+ This for method chaining
2087
+ """
2063
2088
self ._commit_if_ref_updates_exist ()
2064
2089
if (not snapshot_id or ref_name ) and (snapshot_id or not ref_name ):
2065
2090
raise ValidationError ("Either snapshot_id or ref must be provided" )
0 commit comments