Skip to content

Commit 8f1f9b9

Browse files
committed
refactor: update _get_existing_manifests to avoid hardcoding for the child classes
1 parent 9681ec3 commit 8f1f9b9

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

pyiceberg/table/update/snapshot.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def _calculate_added_rows(self, manifests: list[ManifestFile]) -> int:
165165
added_rows += manifest.added_rows_count
166166
return added_rows
167167

168-
def _get_existing_manifests(self) -> list[ManifestFile]:
168+
def _get_existing_manifests(self, should_use_manifest_pruning: bool = False) -> list[ManifestFile]:
169169
"""Filter existing manifests and rewrite those containing deleted data files."""
170170
existing_files: list[ManifestFile] = []
171171
# Use manifest pruning if a predicate is set (primarily for Overwrite)
@@ -174,9 +174,7 @@ def _get_existing_manifests(self) -> list[ManifestFile]:
174174
if snapshot := self._transaction.table_metadata.snapshot_by_name(name=self._target_branch):
175175
for manifest_file in snapshot.manifests(io=self._io):
176176
# Skip pruning for rewrite operations unless we want to optimize later
177-
if self._operation == Operation.OVERWRITE and not manifest_evaluators[manifest_file.partition_spec_id](
178-
manifest_file
179-
):
177+
if should_use_manifest_pruning and not manifest_evaluators[manifest_file.partition_spec_id](manifest_file):
180178
existing_files.append(manifest_file)
181179
continue
182180

@@ -629,7 +627,7 @@ class _OverwriteFiles(_SnapshotProducer["_OverwriteFiles"]):
629627

630628
def _existing_manifests(self) -> list[ManifestFile]:
631629
"""Determine if there are any existing manifest files."""
632-
return self._get_existing_manifests()
630+
return self._get_existing_manifests(should_use_manifest_pruning=True)
633631

634632
def _deleted_entries(self) -> list[ManifestEntry]:
635633
"""To determine if we need to record any deleted entries.

0 commit comments

Comments
 (0)