@@ -435,24 +435,6 @@ def _set_ref_snapshot(
435
435
436
436
return updates , requirements
437
437
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
-
456
438
def update_schema (self , allow_incompatible_changes : bool = False , case_sensitive : bool = True ) -> UpdateSchema :
457
439
"""Create a new UpdateSchema to alter the columns of this table.
458
440
@@ -2010,6 +1992,30 @@ def _commit(self) -> UpdatesAndRequirements:
2010
1992
"""Apply the pending changes and commit."""
2011
1993
return self ._updates , self ._requirements
2012
1994
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
+
2013
2019
def create_tag (self , snapshot_id : int , tag_name : str , max_ref_age_ms : Optional [int ] = None ) -> ManageSnapshots :
2014
2020
"""
2015
2021
Create a new tag pointing to the given snapshot id.
@@ -2042,10 +2048,7 @@ def remove_tag(self, tag_name: str) -> ManageSnapshots:
2042
2048
Returns:
2043
2049
This for method chaining
2044
2050
"""
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 )
2049
2052
2050
2053
def create_branch (
2051
2054
self ,
@@ -2088,10 +2091,7 @@ def remove_branch(self, branch_name: str) -> ManageSnapshots:
2088
2091
Returns:
2089
2092
This for method chaining
2090
2093
"""
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 )
2095
2095
2096
2096
2097
2097
class UpdateSchema (UpdateTableMetadata ["UpdateSchema" ]):
0 commit comments