Index: ql/src/java/org/apache/hadoop/hive/ql/history/HiveHistory.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/history/HiveHistory.java (revision 1214129) +++ ql/src/java/org/apache/hadoop/hive/ql/history/HiveHistory.java (working copy) @@ -234,7 +234,7 @@ // Create directory File f = new File(conf_file_loc); if (!f.exists()) { - if (!f.mkdir()) { + if (!f.mkdirs()) { console.printError("Unable to create log directory " + conf_file_loc); return; } Index: ql/src/test/org/apache/hadoop/hive/ql/history/TestHiveHistory.java =================================================================== --- ql/src/test/org/apache/hadoop/hive/ql/history/TestHiveHistory.java (revision 1214129) +++ ql/src/test/org/apache/hadoop/hive/ql/history/TestHiveHistory.java (working copy) @@ -187,4 +187,29 @@ } } + public void testQueryloglocParentDirNotExist() throws Exception { + String parentTmpDir = tmpdir + "/HIVE2654"; + Path parentDirPath = new Path(parentTmpDir); + try { + fs.delete(parentDirPath, true); + } catch (Exception e) { + } + try { + String actualDir = parentTmpDir + "/test"; + HiveConf conf = new HiveConf(SessionState.class); + conf.set(HiveConf.ConfVars.HIVEHISTORYFILELOC.toString(), actualDir); + SessionState ss = new CliSessionState(conf); + HiveHistory hiveHistory = new HiveHistory(ss); + Path actualPath = new Path(actualDir); + if (!fs.exists(actualPath)) { + fail("Query location path is not exist :" + actualPath.toString()); + } + } finally { + try { + fs.delete(parentDirPath, true); + } catch (Exception e) { + } + } + } + }