You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/12/13 18:37:13 UTC

[GitHub] [iceberg] amogh-jahagirdar commented on a diff in pull request #6090: Core: Handle statistics file clean up from expireSnapshots

amogh-jahagirdar commented on code in PR #6090:
URL: https://github.com/apache/iceberg/pull/6090#discussion_r1047584271


##########
core/src/main/java/org/apache/iceberg/FileCleanupStrategy.java:
##########
@@ -83,4 +85,25 @@ protected void deleteFiles(Set<String> pathsToDelete, String fileType) {
             (file, thrown) -> LOG.warn("Delete failed for {} file: {}", fileType, file, thrown))
         .run(deleteFunc::accept);
   }
+
+  protected Set<String> expiredStatisticsFilesLocations(
+      TableMetadata beforeExpiration, TableMetadata afterExpiration) {
+    Set<String> statisticsFilesLocationBeforeExpiry = allStatisticsFilesLocation(beforeExpiration);
+    Set<String> statisticsFilesLocationAfterExpiry = allStatisticsFilesLocation(afterExpiration);
+    statisticsFilesLocationBeforeExpiry.removeAll(statisticsFilesLocationAfterExpiry);
+    return statisticsFilesLocationBeforeExpiry;
+  }
+
+  private Set<String> allStatisticsFilesLocation(TableMetadata tableMetadata) {
+    Set<String> allStatisticsFilesLocation;
+    if (tableMetadata.statisticsFiles() != null) {
+      allStatisticsFilesLocation =
+          tableMetadata.statisticsFiles().stream()
+              .map(StatisticsFile::path)
+              .collect(Collectors.toSet());
+    } else {
+      allStatisticsFilesLocation = Sets.newHashSet();
+    }
+    return allStatisticsFilesLocation;

Review Comment:
   Nit: I think we could just initialize `allStatisticsFile = Sets.newHashSet()`and remove the else block. Also newline after the block/before the return.



##########
core/src/main/java/org/apache/iceberg/IncrementalFileCleanup.java:
##########
@@ -264,6 +264,14 @@ public void cleanFiles(TableMetadata beforeExpiration, TableMetadata afterExpira
     LOG.warn("Manifests Lists to delete: {}", Joiner.on(", ").join(manifestListsToDelete));
     deleteFiles(manifestsToDelete, "manifest");
     deleteFiles(manifestListsToDelete, "manifest list");
+
+    if (!beforeExpiration.statisticsFiles().isEmpty()) {
+      Set<String> expiredStatisticsFilesLocations =
+          expiredStatisticsFilesLocations(beforeExpiration, afterExpiration);
+      LOG.warn(
+          "Statistics files to delete: {}", Joiner.on(", ").join(expiredStatisticsFilesLocations));

Review Comment:
   I know it was warn level for the other cases in incremental file cleanup, but it seems like something we shouldn't keep following IMO because it's not really a warning case. We know we want to delete these files and it's intentional. 
   
   I think this could be debug level or we can simply remove it.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org