@@ -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:
@@ -431,19 +433,14 @@ def update_schema(self, allow_incompatible_changes: bool = False, case_sensitive
431433 )
432434
433435 def update_snapshot (
434- self , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = None , stage_only : bool = False
436+ self , snapshot_properties : Dict [str , str ] = EMPTY_DICT , branch : Optional [str ] = MAIN_BRANCH
435437 ) -> UpdateSnapshot :
436438 """Create a new UpdateSnapshot to produce a new snapshot for the table.
437439
438440 Returns:
439441 A new UpdateSnapshot
440442 """
441- if branch is None :
442- branch = MAIN_BRANCH
443-
444- return UpdateSnapshot (
445- self , io = self ._table .io , branch = branch , snapshot_properties = snapshot_properties , stage_only = stage_only
446- )
443+ return UpdateSnapshot (self , io = self ._table .io , branch = branch , snapshot_properties = snapshot_properties )
447444
448445 def update_statistics (self ) -> UpdateStatistics :
449446 """
@@ -454,7 +451,7 @@ def update_statistics(self) -> UpdateStatistics:
454451 """
455452 return UpdateStatistics (transaction = self )
456453
457- 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 :
458455 """
459456 Shorthand API for appending a PyArrow table to a table transaction.
460457
@@ -499,7 +496,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
499496 append_files .append_data_file (data_file )
500497
501498 def dynamic_partition_overwrite (
502- 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
503500 ) -> None :
504501 """
505502 Shorthand for overwriting existing partitions with a PyArrow table.
@@ -566,7 +563,7 @@ def overwrite(
566563 overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
567564 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
568565 case_sensitive : bool = True ,
569- branch : Optional [str ] = None ,
566+ branch : Optional [str ] = MAIN_BRANCH ,
570567 ) -> None :
571568 """
572569 Shorthand for adding a table overwrite with a PyArrow table to the transaction.
@@ -632,7 +629,7 @@ def delete(
632629 delete_filter : Union [str , BooleanExpression ],
633630 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
634631 case_sensitive : bool = True ,
635- branch : Optional [str ] = None ,
632+ branch : Optional [str ] = MAIN_BRANCH ,
636633 ) -> None :
637634 """
638635 Shorthand for deleting record from a table.
@@ -735,7 +732,7 @@ def upsert(
735732 when_matched_update_all : bool = True ,
736733 when_not_matched_insert_all : bool = True ,
737734 case_sensitive : bool = True ,
738- branch : Optional [str ] = None ,
735+ branch : Optional [str ] = MAIN_BRANCH ,
739736 ) -> UpsertResult :
740737 """Shorthand API for performing an upsert to an iceberg table.
741738
@@ -820,7 +817,7 @@ def upsert(
820817 case_sensitive = case_sensitive ,
821818 )
822819
823- if branch is not None :
820+ if branch in self . table_metadata . refs :
824821 matched_iceberg_record_batches_scan = matched_iceberg_record_batches_scan .use_ref (branch )
825822
826823 matched_iceberg_record_batches = matched_iceberg_record_batches_scan .to_arrow_batch_reader ()
@@ -1311,7 +1308,7 @@ def upsert(
13111308 when_matched_update_all : bool = True ,
13121309 when_not_matched_insert_all : bool = True ,
13131310 case_sensitive : bool = True ,
1314- branch : Optional [str ] = None ,
1311+ branch : Optional [str ] = MAIN_BRANCH ,
13151312 ) -> UpsertResult :
13161313 """Shorthand API for performing an upsert to an iceberg table.
13171314
@@ -1358,7 +1355,7 @@ def upsert(
13581355 branch = branch ,
13591356 )
13601357
1361- 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 :
13621359 """
13631360 Shorthand API for appending a PyArrow table to the table.
13641361
@@ -1371,7 +1368,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
13711368 tx .append (df = df , snapshot_properties = snapshot_properties , branch = branch )
13721369
13731370 def dynamic_partition_overwrite (
1374- 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
13751372 ) -> None :
13761373 """Shorthand for dynamic overwriting the table with a PyArrow table.
13771374
@@ -1390,7 +1387,7 @@ def overwrite(
13901387 overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
13911388 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
13921389 case_sensitive : bool = True ,
1393- branch : Optional [str ] = None ,
1390+ branch : Optional [str ] = MAIN_BRANCH ,
13941391 ) -> None :
13951392 """
13961393 Shorthand for overwriting the table with a PyArrow table.
@@ -1423,7 +1420,7 @@ def delete(
14231420 delete_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
14241421 snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
14251422 case_sensitive : bool = True ,
1426- branch : Optional [str ] = None ,
1423+ branch : Optional [str ] = MAIN_BRANCH ,
14271424 ) -> None :
14281425 """
14291426 Shorthand for deleting rows from the table.
0 commit comments