Skip to content

Commit f7e192a

Browse files
committed
improve docstrings
1 parent ca63831 commit f7e192a

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

pyiceberg/table/__init__.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,15 @@ def create_branch(
20332033
return self
20342034

20352035
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+
"""
20372045
self._commit_if_ref_updates_exist()
20382046
if self._transaction._table.snapshot_by_id(snapshot_id) is None:
20392047
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:
20462054
return self
20472055

20482056
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+
"""
20502066
self._commit_if_ref_updates_exist()
20512067
if (snapshot := self._transaction._table.snapshot_as_of_timestamp(timestamp, inclusive=False)) is None:
20522068
raise ValidationError(f"Cannot roll back, no valid snapshot older than: {timestamp}")
@@ -2059,7 +2075,16 @@ def rollback_to_timestamp(self, timestamp: int) -> ManageSnapshots:
20592075
return self
20602076

20612077
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+
"""
20632088
self._commit_if_ref_updates_exist()
20642089
if (not snapshot_id or ref_name) and (snapshot_id or not ref_name):
20652090
raise ValidationError("Either snapshot_id or ref must be provided")

0 commit comments

Comments
 (0)