@@ -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:
@@ -431,19 +433,14 @@ def update_schema(self, allow_incompatible_changes: bool = False, case_sensitive
431
433
)
432
434
433
435
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
435
437
) -> UpdateSnapshot :
436
438
"""Create a new UpdateSnapshot to produce a new snapshot for the table.
437
439
438
440
Returns:
439
441
A new UpdateSnapshot
440
442
"""
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 )
447
444
448
445
def update_statistics (self ) -> UpdateStatistics :
449
446
"""
@@ -454,7 +451,7 @@ def update_statistics(self) -> UpdateStatistics:
454
451
"""
455
452
return UpdateStatistics (transaction = self )
456
453
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 :
458
455
"""
459
456
Shorthand API for appending a PyArrow table to a table transaction.
460
457
@@ -499,7 +496,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
499
496
append_files .append_data_file (data_file )
500
497
501
498
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
503
500
) -> None :
504
501
"""
505
502
Shorthand for overwriting existing partitions with a PyArrow table.
@@ -566,7 +563,7 @@ def overwrite(
566
563
overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
567
564
snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
568
565
case_sensitive : bool = True ,
569
- branch : Optional [str ] = None ,
566
+ branch : Optional [str ] = MAIN_BRANCH ,
570
567
) -> None :
571
568
"""
572
569
Shorthand for adding a table overwrite with a PyArrow table to the transaction.
@@ -632,7 +629,7 @@ def delete(
632
629
delete_filter : Union [str , BooleanExpression ],
633
630
snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
634
631
case_sensitive : bool = True ,
635
- branch : Optional [str ] = None ,
632
+ branch : Optional [str ] = MAIN_BRANCH ,
636
633
) -> None :
637
634
"""
638
635
Shorthand for deleting record from a table.
@@ -735,7 +732,7 @@ def upsert(
735
732
when_matched_update_all : bool = True ,
736
733
when_not_matched_insert_all : bool = True ,
737
734
case_sensitive : bool = True ,
738
- branch : Optional [str ] = None ,
735
+ branch : Optional [str ] = MAIN_BRANCH ,
739
736
) -> UpsertResult :
740
737
"""Shorthand API for performing an upsert to an iceberg table.
741
738
@@ -820,7 +817,7 @@ def upsert(
820
817
case_sensitive = case_sensitive ,
821
818
)
822
819
823
- if branch is not None :
820
+ if branch in self . table_metadata . refs :
824
821
matched_iceberg_record_batches_scan = matched_iceberg_record_batches_scan .use_ref (branch )
825
822
826
823
matched_iceberg_record_batches = matched_iceberg_record_batches_scan .to_arrow_batch_reader ()
@@ -1311,7 +1308,7 @@ def upsert(
1311
1308
when_matched_update_all : bool = True ,
1312
1309
when_not_matched_insert_all : bool = True ,
1313
1310
case_sensitive : bool = True ,
1314
- branch : Optional [str ] = None ,
1311
+ branch : Optional [str ] = MAIN_BRANCH ,
1315
1312
) -> UpsertResult :
1316
1313
"""Shorthand API for performing an upsert to an iceberg table.
1317
1314
@@ -1358,7 +1355,7 @@ def upsert(
1358
1355
branch = branch ,
1359
1356
)
1360
1357
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 :
1362
1359
"""
1363
1360
Shorthand API for appending a PyArrow table to the table.
1364
1361
@@ -1371,7 +1368,7 @@ def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT,
1371
1368
tx .append (df = df , snapshot_properties = snapshot_properties , branch = branch )
1372
1369
1373
1370
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
1375
1372
) -> None :
1376
1373
"""Shorthand for dynamic overwriting the table with a PyArrow table.
1377
1374
@@ -1390,7 +1387,7 @@ def overwrite(
1390
1387
overwrite_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
1391
1388
snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
1392
1389
case_sensitive : bool = True ,
1393
- branch : Optional [str ] = None ,
1390
+ branch : Optional [str ] = MAIN_BRANCH ,
1394
1391
) -> None :
1395
1392
"""
1396
1393
Shorthand for overwriting the table with a PyArrow table.
@@ -1423,7 +1420,7 @@ def delete(
1423
1420
delete_filter : Union [BooleanExpression , str ] = ALWAYS_TRUE ,
1424
1421
snapshot_properties : Dict [str , str ] = EMPTY_DICT ,
1425
1422
case_sensitive : bool = True ,
1426
- branch : Optional [str ] = None ,
1423
+ branch : Optional [str ] = MAIN_BRANCH ,
1427
1424
) -> None :
1428
1425
"""
1429
1426
Shorthand for deleting rows from the table.
0 commit comments