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 1b99781..6623127 100644 --- ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java +++ ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java @@ -342,10 +342,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;