8181from pyiceberg .utils .bin_packing import ListPacker
8282from pyiceberg .utils .concurrent import ExecutorFactory
8383from pyiceberg .utils .properties import property_as_bool , property_as_int
84- from pyiceberg .utils .snapshot import ancestors_between
8584
8685if TYPE_CHECKING :
8786 from pyiceberg .table import Transaction
@@ -256,10 +255,12 @@ def _commit(self) -> UpdatesAndRequirements:
256255
257256 # get current snapshot id and starting snapshot id, and validate that there are no conflicts
258257 from pyiceberg .table import StagedTable
258+
259259 if not isinstance (self ._transaction ._table , StagedTable ):
260260 starting_snapshot = self ._transaction .table_metadata .current_snapshot ()
261261 current_snapshot = self ._transaction ._table .refresh ().metadata .current_snapshot ()
262- self ._validate (starting_snapshot , current_snapshot )
262+ if starting_snapshot is not None and current_snapshot is not None :
263+ self ._validate (starting_snapshot , current_snapshot )
263264
264265 with write_manifest_list (
265266 format_version = self ._transaction .table_metadata .format_version ,
@@ -289,7 +290,7 @@ def _commit(self) -> UpdatesAndRequirements:
289290 (AssertRefSnapshotId (snapshot_id = self ._transaction .table_metadata .current_snapshot_id , ref = "main" ),),
290291 )
291292
292- def _validate (self , starting_snapshot : Optional [ Snapshot ] , current_snapshot : Optional [ Snapshot ] ) -> None :
293+ def _validate (self , starting_snapshot : Snapshot , current_snapshot : Snapshot ) -> None :
293294 # Define allowed operations for each type of operation
294295 allowed_operations = {
295296 Operation .APPEND : {Operation .APPEND , Operation .REPLACE , Operation .OVERWRITE , Operation .DELETE },
@@ -305,7 +306,7 @@ def _validate(self, starting_snapshot: Optional[Snapshot], current_snapshot: Opt
305306 if snapshot .snapshot_id == starting_snapshot .snapshot_id :
306307 break
307308
308- snapshot_operation = snapshot .summary .operation
309+ snapshot_operation = snapshot .summary .operation if snapshot . summary is not None else None
309310
310311 if snapshot_operation not in allowed_operations [self ._operation ]:
311312 raise ValueError (
0 commit comments