@@ -398,7 +398,9 @@ def _build_partition_predicate(self, partition_records: Set[Record]) -> BooleanE
398398 expr = Or (expr , match_partition_expression )
399399 return expr
400400
401- def _append_snapshot_producer (self , snapshot_properties : Dict [str , str ], branch : Optional [str ]) -> _FastAppendFiles :
401+ def _append_snapshot_producer (
402+ self , snapshot_properties : Dict [str , str ], branch : Optional [str ] = MAIN_BRANCH
403+ ) -> _FastAppendFiles :
402404 """Determine the append type based on table properties.
403405
404406 Args:
@@ -439,9 +441,6 @@ def update_snapshot(
439441 Returns:
440442 A new UpdateSnapshot
441443 """
442- if branch is None :
443- branch = MAIN_BRANCH
444-
445444 return UpdateSnapshot (self , io = self ._table .io , branch = branch , snapshot_properties = snapshot_properties )
446445
447446 def update_statistics (self ) -> UpdateStatistics :
@@ -453,7 +452,7 @@ def update_statistics(self) -> UpdateStatistics:
453452 """
454453 return UpdateStatistics (transaction = self )
455454
456- def append (self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None ) -> None :
455+ def append (self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH ) -> None :
457456 """
458457 Shorthand API for appending a PyArrow table to a table transaction.
459458
@@ -492,7 +491,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
492491 append_files .append_data_file (data_file )
493492
494493 def dynamic_partition_overwrite (
495- self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None
494+ self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH
496495 ) -> None :
497496 """
498497 Shorthand for overwriting existing partitions with a PyArrow table.
@@ -559,7 +558,7 @@ def overwrite(
559558 overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
560559 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
561560 case_sensitive : bool = True ,
562- branch : Optional [str ] = None ,
561+ branch : Optional [str ] = MAIN_BRANCH ,
563562 ) -> None :
564563 """
565564 Shorthand for adding a table overwrite with a PyArrow table to the transaction.
@@ -619,7 +618,7 @@ def delete(
619618 delete_filter : Union [str , BooleanExpression ],
620619 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
621620 case_sensitive : bool = True ,
622- branch : Optional [str ] = None ,
621+ branch : Optional [str ] = MAIN_BRANCH ,
623622 ) -> None :
624623 """
625624 Shorthand for deleting record from a table.
@@ -722,7 +721,7 @@ def upsert(
722721 when_matched_update_all : bool = True ,
723722 when_not_matched_insert_all : bool = True ,
724723 case_sensitive : bool = True ,
725- branch : Optional [str ] = None ,
724+ branch : Optional [str ] = MAIN_BRANCH ,
726725 ) -> UpsertResult :
727726 """Shorthand API for performing an upsert to an iceberg table.
728727
@@ -807,7 +806,7 @@ def upsert(
807806 case_sensitive = case_sensitive ,
808807 )
809808
810- if branch is not None :
809+ if branch in self . table_metadata . refs :
811810 matched_iceberg_record_batches_scan = matched_iceberg_record_batches_scan .use_ref (branch )
812811
813812 matched_iceberg_record_batches = matched_iceberg_record_batches_scan .to_arrow_batch_reader ()
@@ -1303,7 +1302,7 @@ def upsert(
13031302 when_matched_update_all : bool = True ,
13041303 when_not_matched_insert_all : bool = True ,
13051304 case_sensitive : bool = True ,
1306- branch : Optional [str ] = None ,
1305+ branch : Optional [str ] = MAIN_BRANCH ,
13071306 ) -> UpsertResult :
13081307 """Shorthand API for performing an upsert to an iceberg table.
13091308
@@ -1350,7 +1349,7 @@ def upsert(
13501349 branch = branch ,
13511350 )
13521351
1353- def append (self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None ) -> None :
1352+ def append (self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH ) -> None :
13541353 """
13551354 Shorthand API for appending a PyArrow table to the table.
13561355
@@ -1363,7 +1362,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
13631362 tx .append (df = df , snapshot_properties = snapshot_properties , branch = branch )
13641363
13651364 def dynamic_partition_overwrite (
1366- self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None
1365+ self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH
13671366 ) -> None :
13681367 """Shorthand for dynamic overwriting the table with a PyArrow table.
13691368
@@ -1382,7 +1381,7 @@ def overwrite(
13821381 overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
13831382 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
13841383 case_sensitive : bool = True ,
1385- branch : Optional [str ] = None ,
1384+ branch : Optional [str ] = MAIN_BRANCH ,
13861385 ) -> None :
13871386 """
13881387 Shorthand for overwriting the table with a PyArrow table.
@@ -1415,7 +1414,7 @@ def delete(
14151414 delete_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
14161415 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
14171416 case_sensitive : bool = True ,
1418- branch : Optional [str ] = None ,
1417+ branch : Optional [str ] = MAIN_BRANCH ,
14191418 ) -> None :
14201419 """
14211420 Shorthand for deleting rows from the table.
0 commit comments