Index: ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java (revision 1155145) +++ ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java (working copy) @@ -1175,6 +1175,12 @@ assert fs.getFileStatus(partPath).isDir(): "partitions " + partPath + " is not a directory !"; + // If there are no files in this partition then do nothing + if (Utilities.getFileStatusRecurse(partPath, 1, + partPath.getFileSystem(getConf())).length == 0) { + continue; + } + // generate a full partition specification LinkedHashMap fullPartSpec = new LinkedHashMap(partSpec); Warehouse.makeSpecFromName(fullPartSpec, partPath); @@ -1183,7 +1189,7 @@ // finally load the partition -- move the file to the final table address loadPartition(partPath, tableName, fullPartSpec, replace, holdDDLTime, true); LOG.info("New loading path = " + partPath + " with partSpec " + fullPartSpec); - } + } return fullPartSpecs; } catch (IOException e) { throw new HiveException(e);