huaxingao commented on code in PR #19242:
URL: https://github.com/apache/iceberg/pull/19242#discussion_r4777164255


##########
.palantir/revapi.yml:
##########
@@ -1059,6 +1059,19 @@ acceptedBreaks:
         new: "method void 
org.apache.iceberg.io.PositionDeltaWriter<T>::delete(java.lang.CharSequence,\
         \ long, org.apache.iceberg.PartitionSpec, 
org.apache.iceberg.StructLike)"
         justification: "Removing deprecations for 1.13.0"
+      - code: "java.method.numberOfParametersChanged"
+        old: "method 
org.apache.iceberg.RewriteTablePathUtil.RewriteResult<org.apache.iceberg.DeleteFile>\
+        \ 
org.apache.iceberg.RewriteTablePathUtil::rewriteDeleteManifest(org.apache.iceberg.ManifestFile,\
+        \ java.util.Set<java.lang.Long>, org.apache.iceberg.io.OutputFile, 
org.apache.iceberg.io.FileIO,\
+        \ int, java.util.Map<java.lang.Integer, 
org.apache.iceberg.PartitionSpec>,\
+        \ java.lang.String, java.lang.String, java.lang.String) throws 
java.io.IOException"
+        new: "method 
org.apache.iceberg.RewriteTablePathUtil.RewriteResult<org.apache.iceberg.DeleteFile>\
+        \ 
org.apache.iceberg.RewriteTablePathUtil::rewriteDeleteManifest(org.apache.iceberg.ManifestFile,\
+        \ long, java.util.Set<java.lang.Long>, 
org.apache.iceberg.io.OutputFile, org.apache.iceberg.io.FileIO,\
+        \ int, java.util.Map<java.lang.Integer, 
org.apache.iceberg.PartitionSpec>,\
+        \ java.lang.String, java.lang.String, java.lang.String, 
java.util.Map<java.lang.String,\
+        \ java.lang.Long>) throws java.io.IOException"
+        justification: "Removing deprecations for 1.13.0"

Review Comment:
   Can we update the justification message? This change adds a new overload 
rather than removing a deprecated one. Maybe something like "Add sequence 
number overload for RewriteTablePath copy plan".



##########
core/src/main/java/org/apache/iceberg/RewriteTablePathUtil.java:
##########
@@ -380,6 +385,69 @@ public static RewriteResult<DataFile> rewriteDataManifest(
       String sourcePrefix,
       String targetPrefix)
       throws IOException {
+    return writeDataManifest(
+        manifestFile,
+        entry -> snapshotIds.contains(entry.snapshotId()),
+        outputFile,
+        io,
+        format,
+        specsById,
+        sourcePrefix,
+        targetPrefix);
+  }
+
+  /**
+   * Rewrite a data manifest, replacing path references.
+   *
+   * <p>The copy plan holds the live entries committed after the start 
version: entries whose file
+   * sequence number is greater than {@code startSequenceNumber}, or, when 
sequence numbers are not
+   * available, entries added by a snapshot that is not in {@code 
startSnapshotIds}. Pass 0 and an
+   * empty set to include every live entry.
+   *
+   * @param manifestFile source manifest file to rewrite
+   * @param startSequenceNumber last sequence number of the start version, or 
0 if it has none
+   * @param startSnapshotIds ids of the snapshots in the start version

Review Comment:
   The old method's `snapshotIds` are the snapshots to copy, while these are 
the snapshots to skip. Could we explicitly say that, so someone switching from 
the old method doesn't pass the same set? For example:
   
   ```suggestion
      * @param startSnapshotIds ids of the snapshots in the start version, 
whose entries are excluded
      *     from the copy plan when sequence numbers are not available
   ```
   
   Same for `rewriteDeleteManifest` (line 537).



##########
spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/actions/RewriteTablePathSparkAction.java:
##########
@@ -535,26 +530,11 @@ private RewriteResult<ManifestFile> rewriteManifestList(
     return result;
   }
 
-  private Set<String> manifestsToRewrite(
-      Set<Snapshot> deltaSnapshots, TableMetadata startMetadata) {
+  private void validateEndVersionManifests() {
     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());
-      }
+      // read all manifest lists to fail fast on a missing one, without 
collecting to the driver
+      manifestDS(endStaticTable).select("path").count();

Review Comment:
   Nit: this runs a Spark job only to check that the manifest lists can be 
read, and the result isn't used anymore. Is it still needed? 



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