stevenzwu commented on code in PR #13720:
URL: https://github.com/apache/iceberg/pull/13720#discussion_r2292205167


##########
spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/actions/RewriteTablePathSparkAction.java:
##########
@@ -281,24 +281,32 @@ private String rebuildMetadata() {
     // rebuild version files
     RewriteResult<Snapshot> rewriteVersionResult = 
rewriteVersionFiles(endMetadata);
     Set<Snapshot> deltaSnapshots = deltaSnapshots(startMetadata, 
rewriteVersionResult.toRewrite());
-
-    Set<String> manifestsToRewrite = manifestsToRewrite(deltaSnapshots, 
startMetadata);
     Set<Snapshot> validSnapshots =
         Sets.difference(snapshotSet(endMetadata), snapshotSet(startMetadata));
 
+    // rebuild manifest files
+    Set<ManifestFile> manifestsToRewrite = manifestsToRewrite(validSnapshots);

Review Comment:
   
   Here is where I am confused. Previously, `manifestsToRewrite` return 
manifests whose snapshot id is in the `deltaSnapshots`.
   
   Is `deltaSnapshots` and `deltaSnapshots` same? 
   
   ```
     private Set<String> manifestsToRewrite(
         Set<Snapshot> deltaSnapshots, TableMetadata startMetadata) {
       try {
         Table endStaticTable = newStaticTable(endVersionName, table.io());
         Dataset<Row> lastVersionFiles = 
manifestDS(endStaticTable).select("path");
         if (startMetadata == null) {
           return 
Sets.newHashSet(lastVersionFiles.distinct().as(Encoders.STRING()).collectAsList());
         } else {
           Set<Long> deltaSnapshotIds =
               
deltaSnapshots.stream().map(Snapshot::snapshotId).collect(Collectors.toSet());
           return Sets.newHashSet(
               lastVersionFiles
                   .distinct()
                   .filter(
                       functions
                           .column(ManifestFile.SNAPSHOT_ID.name())
                           .isInCollection(deltaSnapshotIds))
                   .as(Encoders.STRING())
                   .collectAsList());
         }
   ```



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