diff --git ql/src/test/queries/clientpositive/drop_deleted_partitions.q ql/src/test/queries/clientpositive/drop_deleted_partitions.q index a758b1b89e..a44a8f1b60 100644 --- ql/src/test/queries/clientpositive/drop_deleted_partitions.q +++ ql/src/test/queries/clientpositive/drop_deleted_partitions.q @@ -15,4 +15,18 @@ show partitions dmp.mp; drop table dmp.mp; +create table dmp.delete_parent_path (c1 int) partitioned by (year string, month string, day string) location '/tmp/delete_parent_path'; + +alter table dmp.delete_parent_path add partition (year='2019', month='07', day='01'); + +show partitions dmp.delete_parent_path; + +dfs -rm -r /tmp/delete_parent_path/year=2019/month=07; + +alter table dmp.delete_parent_path drop partition (year='2019', month='07', day='01'); + +show partitions dmp.delete_parent_path; + +drop table dmp.delete_parent_path; + drop database dmp; diff --git ql/src/test/results/clientpositive/drop_deleted_partitions.q.out ql/src/test/results/clientpositive/drop_deleted_partitions.q.out index bc2e19e5b3..00fc2e4d96 100644 --- ql/src/test/results/clientpositive/drop_deleted_partitions.q.out +++ ql/src/test/results/clientpositive/drop_deleted_partitions.q.out @@ -67,6 +67,53 @@ POSTHOOK: query: drop table dmp.mp POSTHOOK: type: DROPTABLE POSTHOOK: Input: dmp@mp POSTHOOK: Output: dmp@mp +#### A masked pattern was here #### +PREHOOK: type: CREATETABLE +#### A masked pattern was here #### +PREHOOK: Output: database:dmp +PREHOOK: Output: dmp@delete_parent_path +#### A masked pattern was here #### +POSTHOOK: type: CREATETABLE +#### A masked pattern was here #### +POSTHOOK: Output: database:dmp +POSTHOOK: Output: dmp@delete_parent_path +PREHOOK: query: alter table dmp.delete_parent_path add partition (year='2019', month='07', day='01') +PREHOOK: type: ALTERTABLE_ADDPARTS +PREHOOK: Output: dmp@delete_parent_path +POSTHOOK: query: alter table dmp.delete_parent_path add partition (year='2019', month='07', day='01') +POSTHOOK: type: ALTERTABLE_ADDPARTS +POSTHOOK: Output: dmp@delete_parent_path +POSTHOOK: Output: dmp@delete_parent_path@year=2019/month=07/day=01 +PREHOOK: query: show partitions dmp.delete_parent_path +PREHOOK: type: SHOWPARTITIONS +PREHOOK: Input: dmp@delete_parent_path +POSTHOOK: query: show partitions dmp.delete_parent_path +POSTHOOK: type: SHOWPARTITIONS +POSTHOOK: Input: dmp@delete_parent_path +year=2019/month=07/day=01 +#### A masked pattern was here #### +PREHOOK: query: alter table dmp.delete_parent_path drop partition (year='2019', month='07', day='01') +PREHOOK: type: ALTERTABLE_DROPPARTS +PREHOOK: Input: dmp@delete_parent_path +PREHOOK: Output: dmp@delete_parent_path@year=2019/month=07/day=01 +POSTHOOK: query: alter table dmp.delete_parent_path drop partition (year='2019', month='07', day='01') +POSTHOOK: type: ALTERTABLE_DROPPARTS +POSTHOOK: Input: dmp@delete_parent_path +POSTHOOK: Output: dmp@delete_parent_path@year=2019/month=07/day=01 +PREHOOK: query: show partitions dmp.delete_parent_path +PREHOOK: type: SHOWPARTITIONS +PREHOOK: Input: dmp@delete_parent_path +POSTHOOK: query: show partitions dmp.delete_parent_path +POSTHOOK: type: SHOWPARTITIONS +POSTHOOK: Input: dmp@delete_parent_path +PREHOOK: query: drop table dmp.delete_parent_path +PREHOOK: type: DROPTABLE +PREHOOK: Input: dmp@delete_parent_path +PREHOOK: Output: dmp@delete_parent_path +POSTHOOK: query: drop table dmp.delete_parent_path +POSTHOOK: type: DROPTABLE +POSTHOOK: Input: dmp@delete_parent_path +POSTHOOK: Output: dmp@delete_parent_path PREHOOK: query: drop database dmp PREHOOK: type: DROPDATABASE PREHOOK: Input: database:dmp diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java index d9d7a532ad..38e843aeac 100755 --- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java +++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java @@ -373,9 +373,14 @@ public void recycleDirToCmPath(Path f, boolean ifPurge) throws MetaException { } public boolean isEmptyDir(Path path) throws IOException, MetaException { - int listCount = getFs(path).listStatus(path).length; - if (listCount == 0) { - return true; + try { + int listCount = getFs(path).listStatus(path).length; + if (listCount == 0) { + return true; + } + } catch (FileNotFoundException fnfe) { + // File named by path doesn't exist; nothing to validate. + return false; } return false; }