You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jd...@apache.org on 2019/08/06 20:41:19 UTC
[hive] branch master updated: HIVE-22040: Drop partition throws
exception with 'Failed to delete parent: File does not exist' when the
partition's parent path does not exists (xiepengjie reviewed by Jason Dere)
This is an automated email from the ASF dual-hosted git repository.
jdere pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 333264b HIVE-22040: Drop partition throws exception with 'Failed to delete parent: File does not exist' when the partition's parent path does not exists (xiepengjie reviewed by Jason Dere)
333264b is described below
commit 333264b255580f6738b1b82a4a47130cfac38866
Author: Jason Dere <jd...@cloudera.com>
AuthorDate: Tue Aug 6 13:40:13 2019 -0700
HIVE-22040: Drop partition throws exception with 'Failed to delete parent: File does not exist' when the partition's parent path does not exists (xiepengjie reviewed by Jason Dere)
---
.../clientpositive/drop_deleted_partitions.q | 14 +++++++
.../clientpositive/drop_deleted_partitions.q.out | 47 ++++++++++++++++++++++
.../apache/hadoop/hive/metastore/Warehouse.java | 11 +++--
3 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/ql/src/test/queries/clientpositive/drop_deleted_partitions.q b/ql/src/test/queries/clientpositive/drop_deleted_partitions.q
index a758b1b..a44a8f1 100644
--- a/ql/src/test/queries/clientpositive/drop_deleted_partitions.q
+++ b/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 a/ql/src/test/results/clientpositive/drop_deleted_partitions.q.out b/ql/src/test/results/clientpositive/drop_deleted_partitions.q.out
index bc2e19e..00fc2e4 100644
--- a/ql/src/test/results/clientpositive/drop_deleted_partitions.q.out
+++ b/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 a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
index d9d7a53..38e843a 100755
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
@@ -373,9 +373,14 @@ public class Warehouse {
}
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;
}