Skip to content

Commit 43b1378

Browse files
committed
updates
1 parent b7bdb6c commit 43b1378

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

pyiceberg/table/__init__.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -435,24 +435,6 @@ def _set_ref_snapshot(
435435

436436
return updates, requirements
437437

438-
def _remove_ref_snapshot(self, ref_name: str) -> UpdatesAndRequirements:
439-
"""Remove a snapshot ref.
440-
441-
Args:
442-
ref_name: branch / tag name to remove
443-
444-
Returns
445-
The updates and requirements for the remove-snapshot-ref.
446-
"""
447-
updates = (RemoveSnapshotRefUpdate(ref_name=ref_name),)
448-
requirements = (
449-
AssertRefSnapshotId(
450-
snapshot_id=self.table_metadata.refs[ref_name].snapshot_id if ref_name in self.table_metadata.refs else None,
451-
ref=ref_name,
452-
),
453-
)
454-
return updates, requirements
455-
456438
def update_schema(self, allow_incompatible_changes: bool = False, case_sensitive: bool = True) -> UpdateSchema:
457439
"""Create a new UpdateSchema to alter the columns of this table.
458440
@@ -2010,6 +1992,30 @@ def _commit(self) -> UpdatesAndRequirements:
20101992
"""Apply the pending changes and commit."""
20111993
return self._updates, self._requirements
20121994

1995+
def _remove_ref_snapshot(self, ref_name: str) -> ManageSnapshots:
1996+
"""Remove a snapshot ref.
1997+
1998+
Args:
1999+
ref_name: branch / tag name to remove
2000+
2001+
Stages the updates and requirements for the remove-snapshot-ref.
2002+
2003+
Returns
2004+
This method for chaining
2005+
"""
2006+
updates = (RemoveSnapshotRefUpdate(ref_name=ref_name),)
2007+
requirements = (
2008+
AssertRefSnapshotId(
2009+
snapshot_id=self._transaction.table_metadata.refs[ref_name].snapshot_id
2010+
if ref_name in self._transaction.table_metadata.refs
2011+
else None,
2012+
ref=ref_name,
2013+
),
2014+
)
2015+
self._updates += updates
2016+
self._requirements += requirements
2017+
return self
2018+
20132019
def create_tag(self, snapshot_id: int, tag_name: str, max_ref_age_ms: Optional[int] = None) -> ManageSnapshots:
20142020
"""
20152021
Create a new tag pointing to the given snapshot id.
@@ -2042,10 +2048,7 @@ def remove_tag(self, tag_name: str) -> ManageSnapshots:
20422048
Returns:
20432049
This for method chaining
20442050
"""
2045-
update, requirement = self._transaction._remove_ref_snapshot(ref_name=tag_name)
2046-
self._updates += update
2047-
self._requirements += requirement
2048-
return self
2051+
return self._remove_ref_snapshot(ref_name=tag_name)
20492052

20502053
def create_branch(
20512054
self,
@@ -2088,10 +2091,7 @@ def remove_branch(self, branch_name: str) -> ManageSnapshots:
20882091
Returns:
20892092
This for method chaining
20902093
"""
2091-
update, requirement = self._transaction._remove_ref_snapshot(ref_name=branch_name)
2092-
self._updates += update
2093-
self._requirements += requirement
2094-
return self
2094+
return self._remove_ref_snapshot(ref_name=branch_name)
20952095

20962096

20972097
class UpdateSchema(UpdateTableMetadata["UpdateSchema"]):

0 commit comments

Comments
 (0)