@@ -243,6 +243,8 @@ class TableProperties:
243
243
WRITE_PARTITION_SUMMARY_LIMIT_DEFAULT = 0
244
244
245
245
DELETE_MODE = "write.delete.mode"
246
+ DELETE_MODE_COPY_ON_WRITE = "merge-on-read"
247
+ DELETE_MODE_MERGE_ON_READ = "copy-on-write"
246
248
247
249
DEFAULT_NAME_MAPPING = "schema.name-mapping.default"
248
250
FORMAT_VERSION = "format-version"
@@ -301,7 +303,13 @@ def _apply(self, updates: Tuple[TableUpdate, ...], requirements: Tuple[TableRequ
301
303
requirement .validate (self .table_metadata )
302
304
303
305
self ._updates += updates
304
- self ._requirements += requirements
306
+
307
+ # For the requirements, it does not make sense to add a requirement more than once
308
+ # For example, you cannot assert that the current schema has two different IDs
309
+ existing_requirements = {type (requirement ) for requirement in self ._requirements }
310
+ for new_requirement in requirements :
311
+ if type (new_requirement ) not in existing_requirements :
312
+ self ._requirements = self ._requirements + requirements
305
313
306
314
self .table_metadata = update_table_metadata (self .table_metadata , updates )
307
315
@@ -461,8 +469,8 @@ def overwrite(
461
469
update_snapshot .append_data_file (data_file )
462
470
463
471
def delete (self , delete_filter : BooleanExpression , snapshot_properties : Dict [str , str ] = EMPTY_DICT ) -> None :
464
- if ( mode := self .table_metadata .properties .get (TableProperties .DELETE_MODE )) and mode != 'copy-on-write' :
465
- warnings . warn ( "PyIceberg only supports copy on write " )
472
+ if self .table_metadata .properties .get (TableProperties .DELETE_MODE , TableProperties . DELETE_MODE_COPY_ON_WRITE ) == TableProperties . DELETE_MODE_MERGE_ON_READ :
473
+ raise NotImplementedError ( "Merge on read is not yet supported " )
466
474
467
475
with self .update_snapshot (snapshot_properties = snapshot_properties ).delete () as delete_snapshot :
468
476
delete_snapshot .delete_by_predicate (delete_filter )
@@ -2948,7 +2956,7 @@ def _commit(self) -> UpdatesAndRequirements:
2948
2956
),
2949
2957
(
2950
2958
AssertTableUUID (uuid = self ._transaction .table_metadata .table_uuid ),
2951
- # AssertRefSnapshotId(snapshot_id=self._parent_snapshot_id , ref="main"),
2959
+ AssertRefSnapshotId (snapshot_id = self ._transaction . table_metadata . current_snapshot_id , ref = "main" ),
2952
2960
),
2953
2961
)
2954
2962
0 commit comments