Skip to content

Commit c8162a8

Browse files
committed
feat: update _deleted_entries in _RewriteFiles to use the @cached_property
1 parent 59f555e commit c8162a8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

pyiceberg/table/update/snapshot.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def _calculate_added_rows(self, manifests: list[ManifestFile]) -> int:
167167

168168
def _get_existing_manifests(self) -> list[ManifestFile]:
169169
"""Filter existing manifests and rewrite those containing deleted data files."""
170-
existing_files = []
170+
existing_files: list[ManifestFile] = []
171171
# Use manifest pruning if a predicate is set (primarily for Overwrite)
172172
manifest_evaluators: dict[int, Callable[[ManifestFile], bool]] = KeyDefaultDict(self._build_manifest_evaluator)
173173

@@ -206,6 +206,7 @@ def _get_existing_manifests(self) -> list[ManifestFile]:
206206
)
207207
)
208208
existing_files.append(writer.to_manifest_file())
209+
209210
return existing_files
210211

211212
@abstractmethod
@@ -695,7 +696,8 @@ def _commit(self) -> UpdatesAndRequirements:
695696
else:
696697
return (), ()
697698

698-
def _deleted_entries(self) -> list[ManifestEntry]:
699+
@cached_property
700+
def _cached_deleted_entries(self) -> list[ManifestEntry]:
699701
"""Check if we need to mark the files as deleted."""
700702
if self._parent_snapshot_id is not None:
701703
previous_snapshot = self._transaction.table_metadata.snapshot_by_id(self._parent_snapshot_id)
@@ -722,6 +724,10 @@ def _get_entries(manifest: ManifestFile) -> list[ManifestEntry]:
722724
else:
723725
return []
724726

727+
def _deleted_entries(self) -> list[ManifestEntry]:
728+
"""Check if we need to mark the files as deleted."""
729+
return self._cached_deleted_entries
730+
725731
def _existing_manifests(self) -> list[ManifestFile]:
726732
"""To determine if there are any existing manifests."""
727733
return self._get_existing_manifests()

0 commit comments

Comments
 (0)