397090770 commented on a change in pull request #1839:
URL: https://github.com/apache/iceberg/pull/1839#discussion_r533923102



##########
File path: core/src/main/java/org/apache/iceberg/CatalogUtil.java
##########
@@ -90,6 +94,31 @@ public static void dropTableData(FileIO io, TableMetadata 
metadata) {
         .run(io::deleteFile);
   }
 
+  /**
+   * Drops all useless table directories.
+   *
+   * @param io a FileIO to use for deletes
+   * @param tableBaseLocation table base location
+   */
+  public static void dropTableBaseLocation(FileIO io, String 
tableBaseLocation) {
+    try {
+      if (io instanceof HadoopFileIO) {
+        HadoopFileIO hadoopFileIO = (HadoopFileIO) io;
+        Configuration conf = hadoopFileIO.conf();
+        Path path = new Path(tableBaseLocation);
+        FileSystem fs = Util.getFs(path, conf);
+
+        // Because it might be a partitioned table, there might be a partition 
path below the base path,
+        // so we need to delete recursively
+        fs.delete(path, true);
+      } else {
+        io.deleteFile(tableBaseLocation);

Review comment:
       Hi @rdblue Thank you for you reply. I have updated the code based on the 
comments above, can you help me look again.




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

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