Index: ql/src/java/org/apache/hadoop/hive/ql/io/CombineHiveInputFormat.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/io/CombineHiveInputFormat.java (revision 888452) +++ ql/src/java/org/apache/hadoop/hive/ql/io/CombineHiveInputFormat.java (working copy) @@ -259,6 +259,19 @@ LOG.info("number of splits " + result.size()); + // If the input directories are all empty, we end up submitting a job with + // no splits which hangs Hadoop. If this is the case, create an + // empty split that points to the first file in the first directory. + if (result.size() == 0) { + LOG.info("adding empty split"); + Path firstChild = paths[0].getFileSystem(job).listStatus(paths[0])[0].getPath(); + CombineFileSplit emptySplit = new CombineFileSplit(job, new Path[] {firstChild}, + new long[] {0l}, new long[] {0l}, new String[0]); + FixedCombineHiveInputSplit emptySplitWrapper = new FixedCombineHiveInputSplit(job, + new Hadoop20Shims.InputSplitShim(emptySplit)); + result.add(emptySplitWrapper); + } + return result.toArray(new CombineHiveInputSplit[result.size()]); }