diff --git ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java index 1059cb227f..fcf7d059c2 100644 --- ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java +++ ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java @@ -418,9 +418,20 @@ public static boolean isOriginal(Footer footer) { } } } + // if orc file does not have all the columns it is better to stop here than later running into type exceptions + assertFileSchemaHasAllTypes(result); return result; } + private static void assertFileSchemaHasAllTypes(TypeDescription[] foundTypes) { + for (int i = 0; i < foundTypes.length; i++) { + if (foundTypes[i] == null) { + throw new AssertionError("Not enough columns in orc file. Some columns missing a type: " + + Arrays.toString(foundTypes)); + } + } + } + private static void addColumnToIncludes(TypeDescription child, boolean[] result) { for(int col = child.getId(); col <= child.getMaximumId(); ++col) {