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


##########
core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java:
##########
@@ -214,8 +218,15 @@ private boolean requiresRewrite(Set<ManifestFile> 
currentManifests) {
       return true;
     }
 
-    // if any processed manifest is not in the current manifest list, perform 
a full rewrite
-    return rewrittenManifests.stream().anyMatch(manifest -> 
!currentManifests.contains(manifest));
+    // if any processed manifest is not in the current manifest list, or 
inherits other metadata
+    // there, such as a manifest staged earlier in a transaction that retries, 
perform a full
+    // rewrite
+    return rewrittenManifests.stream()
+        .anyMatch(
+            manifest -> {
+              ManifestFile current = 
currentManifestsByPath.get(manifest.path());
+              return current == null || !inheritsSameMetadata(manifest, 
current);

Review Comment:
   Thanks, good catch. Done in fa46ae34a: `getWriter` now uses 
`ops().current().specsById()`, as the reader in `performRewrite` already does. 
The new test `rewriteStagedManifestAfterRetryWithNewPartitionSpec` stages an 
append and a `clusterBy` rewrite in a transaction, then a concurrent commit 
adds a partition spec and appends a file in it. The retry performs the rewrite 
again and reads that manifest; without the change it fails with 
`NullPointerException: ... because "spec" is null` when the writer for the new 
spec is created, and with it both files keep their spec.



-- 
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