@@ -397,7 +397,9 @@ def _build_partition_predicate(self, partition_records: Set[Record]) -> BooleanE
397397 expr = Or (expr , match_partition_expression )
398398 return expr
399399
400- def _append_snapshot_producer (self , snapshot_properties : Dict [str , str ], branch : Optional [str ]) -> _FastAppendFiles :
400+ def _append_snapshot_producer (
401+ self , snapshot_properties : Dict [str , str ], branch : Optional [str ] = MAIN_BRANCH
402+ ) -> _FastAppendFiles :
401403 """Determine the append type based on table properties.
402404
403405 Args:
@@ -430,15 +432,14 @@ def update_schema(self, allow_incompatible_changes: bool = False, case_sensitive
430432 name_mapping = self .table_metadata .name_mapping (),
431433 )
432434
433- def update_snapshot (self , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None ) -> UpdateSnapshot :
435+ def update_snapshot (
436+ self , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH
437+ ) -> UpdateSnapshot :
434438 """Create a new UpdateSnapshot to produce a new snapshot for the table.
435439
436440 Returns:
437441 A new UpdateSnapshot
438442 """
439- if branch is None :
440- branch = MAIN_BRANCH
441-
442443 return UpdateSnapshot (self , io = self ._table .io , branch = branch , snapshot_properties = snapshot_properties )
443444
444445 def update_statistics (self ) -> UpdateStatistics :
@@ -450,7 +451,7 @@ def update_statistics(self) -> UpdateStatistics:
450451 """
451452 return UpdateStatistics (transaction = self )
452453
453- def append (self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None ) -> None :
454+ def append (self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH ) -> None :
454455 """
455456 Shorthand API for appending a PyArrow table to a table transaction.
456457
@@ -495,7 +496,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
495496 append_files .append_data_file (data_file )
496497
497498 def dynamic_partition_overwrite (
498- self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None
499+ self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH
499500 ) -> None :
500501 """
501502 Shorthand for overwriting existing partitions with a PyArrow table.
@@ -562,7 +563,7 @@ def overwrite(
562563 overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
563564 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
564565 case_sensitive : bool = True ,
565- branch : Optional [str ] = None ,
566+ branch : Optional [str ] = MAIN_BRANCH ,
566567 ) -> None :
567568 """
568569 Shorthand for adding a table overwrite with a PyArrow table to the transaction.
@@ -628,7 +629,7 @@ def delete(
628629 delete_filter : Union [str , BooleanExpression ],
629630 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
630631 case_sensitive : bool = True ,
631- branch : Optional [str ] = None ,
632+ branch : Optional [str ] = MAIN_BRANCH ,
632633 ) -> None :
633634 """
634635 Shorthand for deleting record from a table.
@@ -731,7 +732,7 @@ def upsert(
731732 when_matched_update_all : bool = True ,
732733 when_not_matched_insert_all : bool = True ,
733734 case_sensitive : bool = True ,
734- branch : Optional [str ] = None ,
735+ branch : Optional [str ] = MAIN_BRANCH ,
735736 ) -> UpsertResult :
736737 """Shorthand API for performing an upsert to an iceberg table.
737738
@@ -816,7 +817,7 @@ def upsert(
816817 case_sensitive = case_sensitive ,
817818 )
818819
819- if branch is not None :
820+ if branch in self . table_metadata . refs :
820821 matched_iceberg_record_batches_scan = matched_iceberg_record_batches_scan .use_ref (branch )
821822
822823 matched_iceberg_record_batches = matched_iceberg_record_batches_scan .to_arrow_batch_reader ()
@@ -1307,7 +1308,7 @@ def upsert(
13071308 when_matched_update_all : bool = True ,
13081309 when_not_matched_insert_all : bool = True ,
13091310 case_sensitive : bool = True ,
1310- branch : Optional [str ] = None ,
1311+ branch : Optional [str ] = MAIN_BRANCH ,
13111312 ) -> UpsertResult :
13121313 """Shorthand API for performing an upsert to an iceberg table.
13131314
@@ -1354,7 +1355,7 @@ def upsert(
13541355 branch = branch ,
13551356 )
13561357
1357- def append (self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None ) -> None :
1358+ def append (self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH ) -> None :
13581359 """
13591360 Shorthand API for appending a PyArrow table to the table.
13601361
@@ -1367,7 +1368,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
13671368 tx .append (df = df , snapshot_properties = snapshot_properties , branch = branch )
13681369
13691370 def dynamic_partition_overwrite (
1370- self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None
1371+ self , df : pa .Table , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH
13711372 ) -> None :
13721373 """Shorthand for dynamic overwriting the table with a PyArrow table.
13731374
@@ -1386,7 +1387,7 @@ def overwrite(
13861387 overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
13871388 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
13881389 case_sensitive : bool = True ,
1389- branch : Optional [str ] = None ,
1390+ branch : Optional [str ] = MAIN_BRANCH ,
13901391 ) -> None :
13911392 """
13921393 Shorthand for overwriting the table with a PyArrow table.
@@ -1419,7 +1420,7 @@ def delete(
14191420 delete_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
14201421 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
14211422 case_sensitive : bool = True ,
1422- branch : Optional [str ] = None ,
1423+ branch : Optional [str ] = MAIN_BRANCH ,
14231424 ) -> None :
14241425 """
14251426 Shorthand for deleting rows from the table.
0 commit comments