This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 21658356f [hive] Dropping table deletes table directory to avoid 
schema in filesystem exists (#772)
21658356f is described below

commit 21658356f8bd21728c4d3e8669566af35b6b77e8
Author: Nicholas Jiang <[email protected]>
AuthorDate: Fri Apr 7 10:38:02 2023 +0800

    [hive] Dropping table deletes table directory to avoid schema in filesystem 
exists (#772)
---
 .../src/main/java/org/apache/paimon/hive/HiveCatalog.java     | 11 +++++++++++
 .../java/org/apache/paimon/hive/HiveCatalogITCaseBase.java    |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
 
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
index d167c02ca..91db6fada 100644
--- 
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
+++ 
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
@@ -206,6 +206,17 @@ public class HiveCatalog extends AbstractCatalog {
         try {
             client.dropTable(
                     identifier.getDatabaseName(), identifier.getObjectName(), 
true, false, true);
+            // Deletes table directory to avoid schema in filesystem exists 
after dropping hive
+            // table successfully to keep the table consistency between which 
in filesystem and
+            // which in Hive metastore.
+            Path path = getDataTableLocation(identifier);
+            try {
+                if (fileIO.exists(path)) {
+                    fileIO.deleteDirectoryQuietly(path);
+                }
+            } catch (Exception ee) {
+                LOG.error("Delete directory[{}] fail for table {}", path, 
identifier, ee);
+            }
         } catch (TException e) {
             throw new RuntimeException("Failed to drop table " + 
identifier.getFullName(), e);
         }
diff --git 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveCatalogITCaseBase.java
 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveCatalogITCaseBase.java
index d50bb16e2..32e6450aa 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveCatalogITCaseBase.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveCatalogITCaseBase.java
@@ -241,7 +241,7 @@ public abstract class HiveCatalogITCaseBase {
                         .contains("Table Type:         \tEXTERNAL_TABLE      
\tNULL"));
         tEnv.executeSql("DROP TABLE t").await();
         Path tablePath = new Path(path, "test_db.db/t");
-        Assert.assertTrue(tablePath.getFileSystem().exists(tablePath));
+        Assert.assertFalse(tablePath.getFileSystem().exists(tablePath));
     }
 
     @Test

Reply via email to