voonhous commented on code in PR #10322:
URL: https://github.com/apache/hudi/pull/10322#discussion_r1425206777


##########
hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java:
##########
@@ -887,4 +888,28 @@ public interface SerializableFunction<T, R> extends 
Function<T, R>, Serializable
   private static Option<HoodieLogFile> getLatestLogFile(Stream<HoodieLogFile> 
logFiles) {
     return 
Option.fromJavaOptional(logFiles.min(HoodieLogFile.getReverseLogFileComparator()));
   }
+
+  /**
+   * Delete a file or move the file and path to the trash when on the 
distributed file system.
+   *
+   * @param fs                  {@link FileSystem} instance.
+   * @param relativeFilePath    Path to delete.
+   * @param recursive           If path is a directory and set to true, the 
directory is deleted else throws an exception. In case of a file the recursive 
can be set to either true or false.
+   * @return true if delete is successful else false.
+   */
+  public static boolean handleFileSystemDeletion(FileSystem fs, Path 
relativeFilePath, Boolean recursive) throws IOException {

Review Comment:
   There are actually usages that are using `fs.delete` directly. 
   
   For example:
   
   
https://github.com/apache/hudi/blob/9d9a9a302077b7beb7b1f309c1278638a3f11fb8/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala#L856-L873
   
   Would it be better if we also modify direct calls `fs.delete` to use 
`FSUtils.handleFileSystemDeletion` directly in this PR? 
   



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