@@ -307,6 +307,19 @@ def _apply(self, updates: Tuple[TableUpdate, ...], requirements: Tuple[TableRequ
307
307
308
308
return self
309
309
310
+
311
+ def _scan (
312
+ self ,
313
+ row_filter : Union [str , BooleanExpression ] = ALWAYS_TRUE
314
+ ) -> DataScan :
315
+ """Minimal data scan the table with the current state of the transaction"""
316
+ return DataScan (
317
+ table_metadata = self .table_metadata ,
318
+ io = self ._table .io ,
319
+ row_filter = row_filter ,
320
+ )
321
+
322
+
310
323
def upgrade_table_version (self , format_version : TableVersion ) -> Transaction :
311
324
"""Set the table to a certain version.
312
325
@@ -447,6 +460,19 @@ def overwrite(
447
460
for data_file in data_files :
448
461
update_snapshot .append_data_file (data_file )
449
462
463
+ def delete (self , delete_filter : BooleanExpression , snapshot_properties : Dict [str , str ] = EMPTY_DICT ) -> None :
464
+ with self .update_snapshot (snapshot_properties = snapshot_properties ) as snapshot :
465
+ with snapshot .delete () as delete :
466
+ delete .delete (delete_filter )
467
+
468
+ # Check if there are any files that require an actual rewrite of a data file
469
+ if delete .rewrites_needed :
470
+ files = self ._scan ().plan_files ()
471
+
472
+ for file in files :
473
+
474
+
475
+
450
476
def add_files (self , file_paths : List [str ]) -> None :
451
477
"""
452
478
Shorthand API for adding files as data files to the table transaction.
@@ -1345,6 +1371,19 @@ def overwrite(
1345
1371
with self .transaction () as tx :
1346
1372
tx .overwrite (df = df , overwrite_filter = overwrite_filter , snapshot_properties = snapshot_properties )
1347
1373
1374
+ def delete (self , delete_filter : BooleanExpression = ALWAYS_TRUE , snapshot_properties : Dict [str , str ] = EMPTY_DICT ) -> None :
1375
+ """
1376
+ Shorthand for deleting rows from the table
1377
+
1378
+ Args:
1379
+ delete_filter: The predicate that used to remove rows
1380
+ snapshot_properties: Custom properties to be added to the snapshot summary
1381
+ """
1382
+ with self .transaction () as tx :
1383
+ tx .delete (delete_filter = delete_filter , snapshot_properties = snapshot_properties )
1384
+
1385
+
1386
+
1348
1387
def add_files (self , file_paths : List [str ]) -> None :
1349
1388
"""
1350
1389
Shorthand API for adding files as data files to the table.
0 commit comments