ayushtkn commented on code in PR #4730:
URL: https://github.com/apache/polaris/pull/4730#discussion_r3418323275


##########
runtime/service/src/main/java/org/apache/polaris/service/task/TableCleanupTaskHandler.java:
##########
@@ -151,6 +157,34 @@ public boolean handleTask(TaskEntity cleanupTask, 
CallContext callContext) {
     return false;
   }
 
+  private boolean handleViewCleanup(TaskEntity cleanupTask, 
IcebergTableLikeEntity viewEntity) {
+    LOGGER
+        .atInfo()
+        .addKeyValue("viewIdentifier", viewEntity.getTableIdentifier())
+        .addKeyValue("metadataLocation", viewEntity.getMetadataLocation())
+        .log("Handling view metadata cleanup task");
+
+    try (FileIO fileIO = fileIOSupplier.apply(cleanupTask, 
viewEntity.getTableIdentifier())) {
+      if (!TaskUtils.exists(viewEntity.getMetadataLocation(), fileIO)) {
+        LOGGER
+            .atWarn()
+            .addKeyValue("viewIdentifier", viewEntity.getTableIdentifier())
+            .addKeyValue("metadataLocation", viewEntity.getMetadataLocation())
+            .log("View metadata cleanup scheduled, but metadata file does not 
exist");
+        return true;
+      }
+
+      fileIO.deleteFile(viewEntity.getMetadataLocation());

Review Comment:
   This is the same behaviour as in Iceberg code
   
https://github.com/apache/iceberg/blob/6976e020b894f6a6777704df2b8c4458cb291ae9/core/src/main/java/org/apache/iceberg/CatalogUtil.java#L149-L163
   
   `ViewMetadata` doesn't support having `previous` files `TableMetadata` does.
   
   There is hack possible, if we just get the current file and do a prefix 
match and delete all the files in the directory, but that technically can screw 
us in case someone configured multiple views to share same directory



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

Reply via email to