Index: ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInFile.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInFile.java (revision 8ad7b1f737efb627e155f6cf28869df428ab21b3) +++ ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInFile.java (revision ) @@ -106,16 +106,28 @@ arguments[0].get(), strObjectInspector).toString(); if (set == null) { - String fileName = (String)ObjectInspectorUtils.copyToStandardJavaObject( + String filePath = (String)ObjectInspectorUtils.copyToStandardJavaObject( arguments[1].get(), fileObjectInspector); + load(getFileStreamFor(filePath)); + } + + return Boolean.valueOf(set.contains(str)); + } + + private FileInputStream getFileStreamFor(String filePath) throws HiveException { - try { + try { - load(new FileInputStream((new File(fileName)).getName())); - } catch (FileNotFoundException e) { + // Try opening the file with just file-name. + return new FileInputStream((new File(filePath)).getName()); + } + catch(FileNotFoundException exception) { + // Couldn't find the file-name directly. Attempt full file-path. + try { + return new FileInputStream(filePath); + } + catch(FileNotFoundException e) { throw new HiveException(e); } } - - return Boolean.valueOf(set.contains(str)); } /**