smaheshwar-pltr commented on code in PR #16796:
URL: https://github.com/apache/iceberg/pull/16796#discussion_r3548115021


##########
core/src/main/java/org/apache/iceberg/CatalogUtil.java:
##########
@@ -597,12 +598,18 @@ public static void deleteRemovedMetadataFiles(
       // the log, thus we don't include metadata.previousFiles() for deletion 
- everything else can
       // be removed
       removedPreviousMetadataFiles.removeAll(metadata.previousFiles());
-      deleteFiles(
-          io,
+
+      Set<String> metadataFilesToDelete =
           removedPreviousMetadataFiles.stream()
               .map(TableMetadata.MetadataLogEntry::file)
-              .collect(Collectors.toSet()),
-          "metadata");
+              .collect(Collectors.toCollection(Sets::newHashSet));
+      // delete base's metadata file too if log is empty
+      if (metadata.previousFiles().isEmpty()

Review Comment:
   Might you elaborate on what you had in mind here?
   
   If it's something like
   
   ```java
   Stream.concat(removed…, shouldRemove ? 
Stream.of(base.metadataFileLocation()) : Stream.empty())
   ```
   
   happy to go with that.
   
   Alternatively - I'd originally expressed this as a single set difference of
   
   ```java
   base.previousFiles() + base.metadataFileLocation() − 
metadata.previousFiles() − metadata.metadataFileLocation()
   ```
   
   but I then felt this was a scarier change to make on a public utility method 
that might be used out-of-tree than this PR warrants, hence I refactored.



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