diff --git shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java index e60c5de13d..cbac3fdf25 100644 --- shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java +++ shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java @@ -131,6 +131,11 @@ public RecordReader getRecordReader(InputSplit split, Iterator it = result.iterator(); while (it.hasNext()) { FileStatus stat = it.next(); + // in case of some hadoop version, e.x. hadoop 2.2, nullscan path returned from super.listStatus(job) + // doesn't contain a schema, it will lead NPE because getScheme() returns NULL + if (stat.getPath().toUri().getScheme() == null) { + recoverNullSchemaFileStatus(stat); + } if (!stat.isFile() || (stat.getLen() == 0 && !stat.getPath().toUri().getScheme().equals("nullscan"))) { it.remove(); } @@ -1242,6 +1247,10 @@ private int compareKeyStrength(String keyname1, String keyname2) throws IOExcept } } + private void recoverNullSchemaFileStatus(FileStatus stat) { + stat.setPath(new Path("nullscan://null/", stat.getPath())); + } + @Override public HadoopShims.HdfsEncryptionShim createHdfsEncryptionShim(FileSystem fs, Configuration conf) throws IOException { if (isHdfsEncryptionSupported()) {