JingsongLi commented on code in PR #4824:
URL: https://github.com/apache/paimon/pull/4824#discussion_r1901545405


##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/orphan/SparkOrphanFilesClean.scala:
##########
@@ -145,22 +148,31 @@ case class SparkOrphanFilesClean(
             deletedFilesLenInBytes += fileInfo.getLong(2)
             specifiedFileCleaner.accept(deletedPath)
             logInfo(s"Cleaned file: $pathToClean")
+            involvedDirectories.add(deletedPath.getParent.toUri.toString)
             deletedFilesCount += 1
           }
           logInfo(
             s"Total cleaned files: $deletedFilesCount, Total cleaned files len 
: $deletedFilesLenInBytes")
-          Iterator.single((deletedFilesCount, deletedFilesLenInBytes))
+          Iterator.single((deletedFilesCount, deletedFilesLenInBytes, 
involvedDirectories))
       }
+      .cache()
+
+    // clean empty directories
+    val deletedPaths =
+      deleted.flatMap { case (_, _, paths) => paths }.collect().map(new 
Path(_)).toSet
+    cleanEmptyDirectory(deletedPaths.asJava)

Review Comment:
   You should use Spark distributed RDD or DataFrame to clean them.



-- 
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-unsubscr...@paimon.apache.org

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

Reply via email to