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 2020/12/02 06:21:38 UTC

[GitHub] [iceberg] 397090770 commented on a change in pull request #1839: Remove useless table directories when use HiveCatalog.dropTable and purge is true

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:
users@infra.apache.org



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