shivadarshan-devadiga commented on code in PR #19027:
URL: https://github.com/apache/iceberg/pull/19027#discussion_r4731555310


##########
core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java:
##########
@@ -284,17 +295,39 @@ private boolean matchesPredicate(ManifestFile manifest) {
   }
 
   private void validateDeletedManifests(
-      Set<ManifestFile> currentManifests, long currentSnapshotID) {
-    // directly deleted manifests must be still present in the current snapshot
-    deletedManifests.stream()
-        .filter(manifest -> !currentManifests.contains(manifest))
-        .findAny()
-        .ifPresent(
-            manifest -> {
-              throw new ValidationException(
-                  "Deleted manifest %s could not be found in the latest 
snapshot %d",
-                  manifest.path(), currentSnapshotID);
-            });
+      Map<String, ManifestFile> currentManifestsByPath, long 
currentSnapshotID) {
+    for (ManifestFile manifest : deletedManifests) {
+      // directly deleted manifests must be still present in the current 
snapshot
+      ManifestFile current = currentManifestsByPath.get(manifest.path());
+      ValidationException.check(
+          current != null,
+          "Deleted manifest %s could not be found in the latest snapshot %d",
+          manifest.path(),
+          currentSnapshotID);
+
+      // a replacement written from the entries of a manifest that inherits 
other metadata now would
+      // not have it
+      ValidationException.check(
+          inheritsSameMetadata(manifest, current),
+          "Deleted manifest %s changed in the latest snapshot %d: "
+              + "sequence number %s -> %s, min sequence number %s -> %s, first 
row ID %s -> %s",

Review Comment:
   Thanks. Rather than reject it, the check now compares only the metadata the 
given manifest has: a sequence number of -1 (`ManifestWriter.UNASSIGNED_SEQ`) 
or a NULL first row ID means it was never read back from a snapshot, so there 
is nothing to compare, and it behaves as before this PR. A manifest from the 
snapshot, such as the staged one this PR is about, has them assigned and is 
still checked. `deleteManifestWrittenButNotReadFromSnapshot` appends the 
manifest `ManifestWriter.toManifestFile()` returns and then deletes it with 
that object; without the change it failed with `Deleted manifest ... changed in 
the latest snapshot` on format versions 2 to 4.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to