@@ -2015,7 +2015,15 @@ def create_branch(
2015
2015
return self
2016
2016
2017
2017
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
+ """
2019
2027
self ._commit_if_ref_updates_exist ()
2020
2028
if self ._transaction ._table .snapshot_by_id (snapshot_id ) is None :
2021
2029
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:
2028
2036
return self
2029
2037
2030
2038
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
+ """
2032
2048
self ._commit_if_ref_updates_exist ()
2033
2049
if (snapshot := self ._transaction ._table .snapshot_as_of_timestamp (timestamp , inclusive = False )) is None :
2034
2050
raise ValidationError (f"Cannot roll back, no valid snapshot older than: { timestamp } " )
@@ -2041,7 +2057,16 @@ def rollback_to_timestamp(self, timestamp: int) -> ManageSnapshots:
2041
2057
return self
2042
2058
2043
2059
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
+ """
2045
2070
self ._commit_if_ref_updates_exist ()
2046
2071
if (not snapshot_id or ref_name ) and (snapshot_id or not ref_name ):
2047
2072
raise ValidationError ("Either snapshot_id or ref must be provided" )
0 commit comments