Index: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (revision 1355510) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (working copy) @@ -1683,7 +1683,7 @@ SessionState ss = SessionState.get(); String progName = getScriptProgName(cmd); - if (progName.matches("("+ SessionState.getMatchingSchemaAsRegex() +")://.*")) { + if (SessionState.canDownloadResource(progName)) { String filePath = ss.add_resource(ResourceType.FILE, progName, true); if (filePath == null) { throw new RuntimeException("Could not download the resource: " + progName); Index: ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java (revision 1355510) +++ ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java (working copy) @@ -590,16 +590,17 @@ } /** - * Returns the list of filesystem schemas as regex which - * are permissible for download as a resource. + * Returns true if it is from any external File Systems except local */ - public static String getMatchingSchemaAsRegex() { - String[] matchingSchema = {"s3", "s3n", "hdfs"}; - return StringUtils.join(matchingSchema, "|"); + public static boolean canDownloadResource(String value) { + // Allow to download resources from any external FileSystem. + // And no need to download if it already exists on local file system. + return value.matches("\\w+://.*") + && !value.toLowerCase().contains("file://"); } private String downloadResource(String value, boolean convertToUnix) { - if (value.matches("("+ getMatchingSchemaAsRegex() +")://.*")) { + if (canDownloadResource(value)) { getConsole().printInfo("converting to local " + value); File resourceDir = new File(getConf().getVar(HiveConf.ConfVars.DOWNLOADED_RESOURCES_DIR)); String destinationName = new Path(value).getName();