diff --git build-common.xml build-common.xml
index a5180c1..ac0ac3e 100644
--- build-common.xml
+++ build-common.xml
@@ -59,7 +59,7 @@
-
+
diff --git ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java
index 3719326..c990dce 100644
--- ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java
+++ ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java
@@ -388,10 +388,22 @@ private static PartitionDesc doGetPartitionDescFromPath(
dirStr = dirStr.substring(0, dirStrIndex);
dirPath = dirPath.substring(0, dirPathIndex);
//first try full match
- part = pathToPartitionInfo.get(dirStr);
+ if (dirPath.length() == 0) {
+ //if the dir is the root directory of the file system and dir does not have a "/"
+ //at the end, we need to make dirStr and dirPath valid by adding "/" at the end
+ part = pathToPartitionInfo.get(dirStr + "/");
+ } else {
+ part = pathToPartitionInfo.get(dirStr);
+ }
if (part == null) {
// LOG.warn("exact match not found, try ripping input path's theme and authority");
- part = pathToPartitionInfo.get(dirPath);
+ if (dirPath.length() == 0) {
+ //if the dir is the root directory of the file system and dir does not have a "/"
+ //at the end, we need to make dirStr and dirPath valid by adding "/" at the end
+ part = pathToPartitionInfo.get(dirPath + "/");
+ } else {
+ part = pathToPartitionInfo.get(dirPath);
+ }
}
if (part != null) {
break;
diff --git ql/src/test/queries/clientpositive/root_dir_external_table.q ql/src/test/queries/clientpositive/root_dir_external_table.q
new file mode 100644
index 0000000..3befe4e
--- /dev/null
+++ ql/src/test/queries/clientpositive/root_dir_external_table.q
@@ -0,0 +1,11 @@
+dfs -mkdir hdfs:///tmp/test;
+
+insert overwrite directory "hdfs:///tmp/test" select key from src where (key < 20) order by key;
+
+dfs -cp /tmp/test/000000_0 /000000_0;
+dfs -rmr hdfs:///tmp/test;
+
+create external table roottable (key string) row format delimited fields terminated by '\\t' stored as textfile location 'hdfs:///';
+select count(*) from roottable;
+
+dfs -rmr /000000_0;
\ No newline at end of file
diff --git ql/src/test/results/clientpositive/root_dir_external_table.q.out ql/src/test/results/clientpositive/root_dir_external_table.q.out
new file mode 100644
index 0000000..dfd8671
--- /dev/null
+++ ql/src/test/results/clientpositive/root_dir_external_table.q.out
@@ -0,0 +1,21 @@
+#### A masked pattern was here ####
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+PREHOOK: type: CREATETABLE
+#### A masked pattern was here ####
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@roottable
+PREHOOK: query: select count(*) from roottable
+PREHOOK: type: QUERY
+PREHOOK: Input: default@roottable
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from roottable
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@roottable
+#### A masked pattern was here ####
+20
+#### A masked pattern was here ####