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 efeb70f91e4d1b041233d7f96ab308f99523e029..9e1c89df8bae3d17ac9084b0e3fd994da2cdc6f8 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 @@ -595,33 +595,42 @@ private void createSessionDirs(String userName) throws IOException { String scratchDirPermission = HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCHDIRPERMISSION); Path path; // 1. HDFS scratch dir - path = new Path(rootHDFSDirPath, userName); + path = makeAbsolute(new Path(rootHDFSDirPath, userName)); hdfsScratchDirURIString = path.toUri().toString(); createPath(conf, path, scratchDirPermission, false, false); // 2. Local scratch dir - path = new Path(HiveConf.getVar(conf, HiveConf.ConfVars.LOCALSCRATCHDIR)); + path = makeAbsolute(new Path(HiveConf.getVar(conf, HiveConf.ConfVars.LOCALSCRATCHDIR))); createPath(conf, path, scratchDirPermission, true, false); // 3. Download resources dir - path = new Path(HiveConf.getVar(conf, HiveConf.ConfVars.DOWNLOADED_RESOURCES_DIR)); + path = makeAbsolute(new Path(HiveConf.getVar(conf, HiveConf.ConfVars.DOWNLOADED_RESOURCES_DIR))); createPath(conf, path, scratchDirPermission, true, false); // Finally, create session paths for this session // Local & non-local tmp location is configurable. however it is the same across // all external file systems String sessionId = getSessionId(); // 4. HDFS session path - hdfsSessionPath = new Path(hdfsScratchDirURIString, sessionId); + hdfsSessionPath = makeAbsolute(new Path(hdfsScratchDirURIString, sessionId)); createPath(conf, hdfsSessionPath, scratchDirPermission, false, true); conf.set(HDFS_SESSION_PATH_KEY, hdfsSessionPath.toUri().toString()); // 5. Local session path - localSessionPath = new Path(HiveConf.getVar(conf, HiveConf.ConfVars.LOCALSCRATCHDIR), sessionId); + localSessionPath = makeAbsolute(new Path(HiveConf.getVar(conf, HiveConf.ConfVars.LOCALSCRATCHDIR), sessionId)); createPath(conf, localSessionPath, scratchDirPermission, true, true); conf.set(LOCAL_SESSION_PATH_KEY, localSessionPath.toUri().toString()); // 6. HDFS temp table space - hdfsTmpTableSpace = new Path(hdfsSessionPath, TMP_PREFIX); + hdfsTmpTableSpace = makeAbsolute(new Path(hdfsSessionPath, TMP_PREFIX)); createPath(conf, hdfsTmpTableSpace, scratchDirPermission, false, true); conf.set(TMP_TABLE_SPACE_KEY, hdfsTmpTableSpace.toUri().toString()); } + private Path makeAbsolute(Path path) throws IOException { + if (path.isAbsolute()) { + return path; + } else { + FileSystem fileSystem = path.getFileSystem(conf); + return new Path(fileSystem.getWorkingDirectory(), path); + } + } + /** * Create the root scratch dir on hdfs (if it doesn't already exist) and make it writable * @param conf