diff --git a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java index b531cc9..b0edbbd 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java @@ -84,6 +84,7 @@ import org.apache.hadoop.hive.shims.Utils; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.util.ReflectionUtils; +import org.apache.hadoop.util.Shell; import com.google.common.base.Preconditions; @@ -1239,10 +1240,15 @@ public static boolean canDownloadResource(String value) { return (scheme != null) && !scheme.equalsIgnoreCase("file"); } - private String downloadResource(String value, boolean convertToUnix) { + private String downloadResource(String value, boolean convertToUnix) throws URISyntaxException { if (canDownloadResource(value)) { getConsole().printInfo("converting to local " + value); - File resourceDir = new File(getConf().getVar(HiveConf.ConfVars.DOWNLOADED_RESOURCES_DIR)); + // If the underlying operating system is windows, convert resourceDir into valid URI syntax. + File resourceDir = Shell.WINDOWS ? + new File(new URI("file:///" + + getConf().getVar(HiveConf.ConfVars. + DOWNLOADED_RESOURCES_DIR).replace('\\', '/')).getPath()) : + new File(getConf().getVar(HiveConf.ConfVars.DOWNLOADED_RESOURCES_DIR)); String destinationName = new Path(value).getName(); File destinationFile = new File(resourceDir, destinationName); if (resourceDir.exists() && ! resourceDir.isDirectory()) {