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


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -191,70 +184,63 @@ protected void failMissingDeletePaths() {
    * @param expr an expression to match rows.
    */
   protected void deleteByRowFilter(Expression expr) {
+    producer.deleteByRowFilter(expr);
     this.deleteExpression = expr;
-    filterManager.deleteByRowFilter(expr);
-    // if a delete file matches the row filter, then it can be deleted because 
the rows will also be
-    // deleted
-    deleteFilterManager.deleteByRowFilter(expr);
+    this.deletesDataFiles = true;
   }
 
   /** Add a partition tuple to drop from the table during the delete phase. */
   protected void dropPartition(int specId, StructLike partition) {
-    // dropping the data in a partition also drops all deletes in the partition
-    filterManager.dropPartition(specId, partition);
-    deleteFilterManager.dropPartition(specId, partition);
+    producer.deletePartition(specId, partition);
+    this.deletesDataFiles = true;
   }
 
   /** Add a specific data file to be deleted in the new snapshot. */
   protected void delete(DataFile file) {
-    filterManager.delete(file);
+    producer.deleteDataFile(file);
+    this.deletesDataFiles = true;
   }
 
   /** Add a specific delete file to be deleted in the new snapshot. */
   protected void delete(DeleteFile file) {
-    deleteFilterManager.delete(file);
+    producer.deleteDeleteFile(file);
+    this.deletesDeleteFiles = true;
   }
 
   /** Add a specific data path to be deleted in the new snapshot. */
   protected void delete(CharSequence path) {
     // this is an old call that never worked for delete files and can only be 
used to remove data
     // files.
-    filterManager.delete(path);
+    producer.deleteDataFile(path);
   }
 
   protected boolean deletesDataFiles() {
-    return filterManager.containsDeletes();
+    return deletesDataFiles;
   }
 
   protected boolean deletesDeleteFiles() {
-    return deleteFilterManager.containsDeletes();
+    return deletesDeleteFiles;
   }
 
   protected boolean addsDataFiles() {
-    return !newDataFilesBySpec.isEmpty();
+    return !appendedDataFiles.isEmpty();
   }
 
   protected boolean addsDeleteFiles() {
-    return !v2Deletes.isEmpty()
-        || dvsByReferencedFile.values().stream().anyMatch(dvs -> 
!dvs.isEmpty());
+    return !addedDeleteFiles.isEmpty();
   }
 
   /** Add a data file to the new snapshot. */
   protected void add(DataFile file) {
     Preconditions.checkNotNull(file, "Invalid data file: null");
-    PartitionSpec spec = spec(file.specId());
-    Preconditions.checkArgument(
-        spec != null,
-        "Cannot find partition spec %s for data file: %s",
-        file.specId(),
-        file.location());
-
-    DataFileSet dataFiles =
-        newDataFilesBySpec.computeIfAbsent(spec.specId(), ignored -> 
DataFileSet.create());
-    if (dataFiles.add(Delegates.suppressFirstRowId(file))) {
-      addedDataFilesSummary.addedFile(spec, file);
-      hasNewDataFiles = true;
-    }
+    producer.appendDataFile(file);
+    appendedDataFiles.add(file);

Review Comment:
   I think that the this behavior is correct. If you add duplicate files, you 
should get them listed back.
   
   I did update the logic to use the deduplicated file list for updating the 
summary. This _should_ throw an exception rather than silently fixing bad 
commits, but we can't change that now and there is no reason to let the summary 
drift.



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