rdblue commented on code in PR #19129:
URL: https://github.com/apache/iceberg/pull/19129#discussion_r4807959804


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -1138,74 +1046,71 @@ protected NewSnapshotMetadata writeRootManifest(
   }
 
   @Override
-  public List<ManifestFile> apply(TableMetadata base, Snapshot snapshot) {
-    validateDeleteFilesForVersion(base.formatVersion());
-    // filter any existing manifests
-    List<ManifestFile> filtered =
-        filterManager.filterManifests(
-            SnapshotUtil.schemaFor(base, targetBranch()),
-            snapshot != null ? snapshot.dataManifests(ops().io()) : null);
-    long minDataSequenceNumber =
-        filtered.stream()
-            .map(ManifestFile::minSequenceNumber)
-            .filter(
-                seq ->
-                    seq
-                        != ManifestWriter
-                            .UNASSIGNED_SEQ) // filter out unassigned in 
rewritten manifests
-            .reduce(base.lastSequenceNumber(), Math::min);
-    deleteFilterManager.dropDeleteFilesOlderThan(minDataSequenceNumber);
-
-    // retrieve the data files to be deleted from the DataFileFilterManager 
and pass it to the
-    // DeleteFileFilterManager so that it can potentially remove orphaned DVs
-    Set<DataFile> filesToBeDeleted = filterManager.filesToBeDeleted();
-    deleteFilterManager.removeDanglingDeletesFor(filesToBeDeleted);
-
-    List<ManifestFile> filteredDeletes =
-        deleteFilterManager.filterManifests(
-            SnapshotUtil.schemaFor(base, targetBranch()),
-            snapshot != null ? snapshot.deleteManifests(ops().io()) : null);
-
-    // only keep manifests that have live data files or that were written by 
this commit
-    Predicate<ManifestFile> shouldKeep =
-        manifest ->
-            manifest.hasAddedFiles()
-                || manifest.hasExistingFiles()
-                || manifest.snapshotId() == snapshotId();
-    Iterable<ManifestFile> unmergedManifests =
-        Iterables.filter(Iterables.concat(prepareNewDataManifests(), 
filtered), shouldKeep);
-    Iterable<ManifestFile> unmergedDeleteManifests =
-        Iterables.filter(Iterables.concat(prepareDeleteManifests(), 
filteredDeletes), shouldKeep);
-
-    // update the snapshot summary
+  public List<ManifestFile> apply(TableMetadata base, Snapshot parent) {
+    ValidationException.check(
+        base.formatVersion() < 4,
+        "Cannot commit to table concurrently upgraded to v%s",
+        base.formatVersion());
+
+    List<ManifestFile> manifests = manifestListProducer.apply(base, parent, 
targetBranch());
+
+    List<DataFile> deletedDataFiles = manifestListProducer.deletedDataFiles();
+    List<DeleteFile> deletedDeleteFiles = 
manifestListProducer.deletedDeleteFiles();
+    if (failAnyDelete) {

Review Comment:
   They could be, but I don't think it is a good idea to add that complexity. 
By adding it to `ProducerActions`, you would be making it the responsibility of 
producers. It is the responsibility of `MergingSnapshotProducer`, not 
necessarily the v3 and v4 handlers.
   
   I don't see a compelling reason to increase the complexity of what those 
handlers are doing. This solution (returning the deleted files and missing 
files) is cleaner.



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