Skip to content

Commit 5cec00a

Browse files
committed
WIP
1 parent a925d69 commit 5cec00a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

pyiceberg/table/__init__.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,19 @@ def _apply(self, updates: Tuple[TableUpdate, ...], requirements: Tuple[TableRequ
307307

308308
return self
309309

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+
310323
def upgrade_table_version(self, format_version: TableVersion) -> Transaction:
311324
"""Set the table to a certain version.
312325
@@ -447,6 +460,19 @@ def overwrite(
447460
for data_file in data_files:
448461
update_snapshot.append_data_file(data_file)
449462

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+
450476
def add_files(self, file_paths: List[str]) -> None:
451477
"""
452478
Shorthand API for adding files as data files to the table transaction.
@@ -1345,6 +1371,19 @@ def overwrite(
13451371
with self.transaction() as tx:
13461372
tx.overwrite(df=df, overwrite_filter=overwrite_filter, snapshot_properties=snapshot_properties)
13471373

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+
13481387
def add_files(self, file_paths: List[str]) -> None:
13491388
"""
13501389
Shorthand API for adding files as data files to the table.

0 commit comments

Comments
 (0)