diff --git itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java index 0f17b1b..870c91d 100644 --- itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java +++ itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java @@ -883,7 +883,12 @@ public String cliInit(String tname, boolean recreate) throws Exception { HiveConf.setVar(conf, HiveConf.ConfVars.HIVE_AUTHENTICATOR_MANAGER, "org.apache.hadoop.hive.ql.security.DummyAuthenticator"); Utilities.clearWorkMap(conf); - CliSessionState ss = createSessionState(); + CliSessionState ss; + if (recreate || !(clusterType == MiniClusterType.llap || clusterType == MiniClusterType.tez)) { + ss = createSessionState(); + } else { + ss = (CliSessionState) SessionState.get(); + } assert ss != null; ss.in = System.in; @@ -910,20 +915,25 @@ public String cliInit(String tname, boolean recreate) throws Exception { } ss.err = new CachingPrintStream(fo, true, "UTF-8"); ss.setIsSilent(true); - SessionState oldSs = SessionState.get(); - if (oldSs != null && (clusterType == MiniClusterType.tez || clusterType == MiniClusterType.llap - || clusterType == MiniClusterType.spark || clusterType == MiniClusterType.miniSparkOnYarn)) { - sparkSession = oldSs.getSparkSession(); - ss.setSparkSession(sparkSession); - oldSs.setSparkSession(null); - oldSs.close(); - } + if (recreate || !(clusterType == MiniClusterType.llap || clusterType == MiniClusterType.tez)) { + SessionState oldSs = SessionState.get(); + + if (oldSs != null && + (clusterType == MiniClusterType.tez || clusterType == MiniClusterType.llap + || clusterType == MiniClusterType.spark || + clusterType == MiniClusterType.miniSparkOnYarn)) { + sparkSession = oldSs.getSparkSession(); + ss.setSparkSession(sparkSession); + oldSs.setSparkSession(null); + oldSs.close(); + } - if (oldSs != null && oldSs.out != null && oldSs.out != System.out) { - oldSs.out.close(); + if (oldSs != null && oldSs.out != null && oldSs.out != System.out) { + oldSs.out.close(); + } + SessionState.start(ss); } - SessionState.start(ss); cliDriver = new CliDriver();