|
19 | 19 | from unittest.mock import patch |
20 | 20 |
|
21 | 21 | from pyiceberg.io import FileIO |
22 | | -from pyiceberg.manifest import ManifestContent, ManifestFile |
| 22 | +from pyiceberg.manifest import ManifestContent, ManifestEntry, ManifestEntryStatus, ManifestFile |
23 | 23 | from pyiceberg.table import Table |
24 | | -from pyiceberg.table.snapshots import Operation, Snapshot |
| 24 | +from pyiceberg.table.snapshots import Operation, Snapshot, Summary |
25 | 25 | from pyiceberg.table.update.validate import deleted_data_files, validation_history |
26 | 26 |
|
27 | 27 |
|
@@ -109,3 +109,34 @@ def mock_read_manifest_side_effect(self: Snapshot, io: FileIO) -> list[ManifestF |
109 | 109 | ) |
110 | 110 |
|
111 | 111 | assert result == [] |
| 112 | + |
| 113 | + # modify second to last snapshot to be a delete |
| 114 | + snapshots = table_v2_with_extensive_snapshots.snapshots() |
| 115 | + altered_snapshot = snapshots[-2] |
| 116 | + altered_snapshot = altered_snapshot.model_copy(update={"summary": Summary(operation=Operation.DELETE)}) |
| 117 | + snapshots[-2] = altered_snapshot |
| 118 | + |
| 119 | + table_v2_with_extensive_snapshots.metadata = table_v2_with_extensive_snapshots.metadata.model_copy( |
| 120 | + update={"snapshots": snapshots}, |
| 121 | + ) |
| 122 | + |
| 123 | + my_entry = ManifestEntry( |
| 124 | + status=ManifestEntryStatus.DELETED, |
| 125 | + snapshot_id=altered_snapshot.snapshot_id, |
| 126 | + ) |
| 127 | + |
| 128 | + with ( |
| 129 | + patch("pyiceberg.table.snapshots.Snapshot.manifests", new=mock_read_manifest_side_effect), |
| 130 | + patch("pyiceberg.manifest.ManifestFile.fetch_manifest_entry", return_value=[my_entry]), |
| 131 | + ): |
| 132 | + result = list( |
| 133 | + deleted_data_files( |
| 134 | + table=table_v2_with_extensive_snapshots, |
| 135 | + starting_snapshot=newest_snapshot, |
| 136 | + data_filter=None, |
| 137 | + parent_snapshot=oldest_snapshot, |
| 138 | + partition_set=None, |
| 139 | + ) |
| 140 | + ) |
| 141 | + |
| 142 | + assert result == [my_entry] |
0 commit comments