@@ -397,7 +397,9 @@ def _build_partition_predicate(self, partition_records: Set[Record]) -> BooleanE
397
397
expr = Or (expr , match_partition_expression )
398
398
return expr
399
399
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 :
401
403
"""Determine the append type based on table properties.
402
404
403
405
Args:
@@ -430,15 +432,14 @@ def update_schema(self, allow_incompatible_changes: bool = False, case_sensitive
430
432
name_mapping = self .table_metadata .name_mapping (),
431
433
)
432
434
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 :
434
438
"""Create a new UpdateSnapshot to produce a new snapshot for the table.
435
439
436
440
Returns:
437
441
A new UpdateSnapshot
438
442
"""
439
- if branch is None :
440
- branch = MAIN_BRANCH
441
-
442
443
return UpdateSnapshot (self , io = self ._table .io , branch = branch , snapshot_properties = snapshot_properties )
443
444
444
445
def update_statistics (self ) -> UpdateStatistics :
@@ -450,7 +451,7 @@ def update_statistics(self) -> UpdateStatistics:
450
451
"""
451
452
return UpdateStatistics (transaction = self )
452
453
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 :
454
455
"""
455
456
Shorthand API for appending a PyArrow table to a table transaction.
456
457
@@ -495,7 +496,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
495
496
append_files .append_data_file (data_file )
496
497
497
498
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
499
500
) -> None :
500
501
"""
501
502
Shorthand for overwriting existing partitions with a PyArrow table.
@@ -562,7 +563,7 @@ def overwrite(
562
563
overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
563
564
snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
564
565
case_sensitive : bool = True ,
565
- branch : Optional [str ] = None ,
566
+ branch : Optional [str ] = MAIN_BRANCH ,
566
567
) -> None :
567
568
"""
568
569
Shorthand for adding a table overwrite with a PyArrow table to the transaction.
@@ -628,7 +629,7 @@ def delete(
628
629
delete_filter : Union [str , BooleanExpression ],
629
630
snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
630
631
case_sensitive : bool = True ,
631
- branch : Optional [str ] = None ,
632
+ branch : Optional [str ] = MAIN_BRANCH ,
632
633
) -> None :
633
634
"""
634
635
Shorthand for deleting record from a table.
@@ -731,7 +732,7 @@ def upsert(
731
732
when_matched_update_all : bool = True ,
732
733
when_not_matched_insert_all : bool = True ,
733
734
case_sensitive : bool = True ,
734
- branch : Optional [str ] = None ,
735
+ branch : Optional [str ] = MAIN_BRANCH ,
735
736
) -> UpsertResult :
736
737
"""Shorthand API for performing an upsert to an iceberg table.
737
738
@@ -816,7 +817,7 @@ def upsert(
816
817
case_sensitive = case_sensitive ,
817
818
)
818
819
819
- if branch is not None :
820
+ if branch in self . table_metadata . refs :
820
821
matched_iceberg_record_batches_scan = matched_iceberg_record_batches_scan .use_ref (branch )
821
822
822
823
matched_iceberg_record_batches = matched_iceberg_record_batches_scan .to_arrow_batch_reader ()
@@ -1307,7 +1308,7 @@ def upsert(
1307
1308
when_matched_update_all : bool = True ,
1308
1309
when_not_matched_insert_all : bool = True ,
1309
1310
case_sensitive : bool = True ,
1310
- branch : Optional [str ] = None ,
1311
+ branch : Optional [str ] = MAIN_BRANCH ,
1311
1312
) -> UpsertResult :
1312
1313
"""Shorthand API for performing an upsert to an iceberg table.
1313
1314
@@ -1354,7 +1355,7 @@ def upsert(
1354
1355
branch = branch ,
1355
1356
)
1356
1357
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 :
1358
1359
"""
1359
1360
Shorthand API for appending a PyArrow table to the table.
1360
1361
@@ -1367,7 +1368,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
1367
1368
tx .append (df = df , snapshot_properties = snapshot_properties , branch = branch )
1368
1369
1369
1370
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
1371
1372
) -> None :
1372
1373
"""Shorthand for dynamic overwriting the table with a PyArrow table.
1373
1374
@@ -1386,7 +1387,7 @@ def overwrite(
1386
1387
overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
1387
1388
snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
1388
1389
case_sensitive : bool = True ,
1389
- branch : Optional [str ] = None ,
1390
+ branch : Optional [str ] = MAIN_BRANCH ,
1390
1391
) -> None :
1391
1392
"""
1392
1393
Shorthand for overwriting the table with a PyArrow table.
@@ -1419,7 +1420,7 @@ def delete(
1419
1420
delete_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
1420
1421
snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
1421
1422
case_sensitive : bool = True ,
1422
- branch : Optional [str ] = None ,
1423
+ branch : Optional [str ] = MAIN_BRANCH ,
1423
1424
) -> None :
1424
1425
"""
1425
1426
Shorthand for deleting rows from the table.
0 commit comments