dramaticlly commented on code in PR #16220:
URL: https://github.com/apache/iceberg/pull/16220#discussion_r4757863682


##########
core/src/main/java/org/apache/iceberg/RewriteTablePathUtil.java:
##########
@@ -480,15 +548,22 @@ private static RewriteResult<DataFile> writeDataFileEntry(
     DataFile newDataFile =
         
DataFiles.builder(spec).copy(entry.file()).withPath(targetDataFilePath).build();
     appendEntryWithFile(entry, writer, newDataFile);
-    // keep the following entries in metadata but exclude them from copyPlan
-    // 1) deleted data files
-    // 2) entries not changed by snapshotIds
-    if (entry.isLive() && snapshotIds.contains(entry.snapshotId())) {
+    if (includeInCopyPlan(entry, snapshotIds)) {
       result.copyPlan().add(Pair.of(sourceDataFilePath, 
newDataFile.location()));
     }
     return result;
   }
 
+  /**
+   * Whether a manifest entry should be added to the copy plan. Every live 
entry is included; when
+   * {@code snapshotIds} is non-null, inclusion is further restricted to 
entries added by one of
+   * those snapshots (legacy filtering). A {@code null} {@code snapshotIds} 
means all live entries
+   * are included.
+   */
+  private static boolean includeInCopyPlan(ManifestEntry<?> entry, Set<Long> 
snapshotIds) {

Review Comment:
   I think this is the core logic we need to decide on which subset of manifest 
entry shall be included in the copy plan. 
   
   The previous snapshot id based filtering rely on the fact the source iceberg 
table and replicated version have common set of snapshot history and use delta 
snapshot id to narrow down the incremental part. However it failed to account 
for snapshot expiration in source and when the delta between source and target 
is too wide it might miss the desired set of manifest entries. 
   
   I have a alternative proposal in #19242  which leverage the file sequence 
number to decide the delta subsets, which is strictly incremental and easy to 
filter both manifests and manifest entry are committed after starting offset, 
so maybe worth taking a look. @krisnaru @mxm 



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