commit 26d15fda58b09c89833f2c8b7fa6367a613de9be Author: Reuben Kuhnert Date: Tue Mar 22 12:53:32 2016 -0500 Test patch for HIVE-12612 Change-Id: I4e290031e51b76af06daa84a3bbfac0b9860b0b1 diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java index 4ab6aa82fbf1b0308e7178f4527c70adacb20214..f95cb6683052420575f9b66c0a5483a7e0261ddd 100644 --- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java +++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java @@ -133,6 +133,7 @@ private final Reflector reflector; private String dbName = null; private String currentDatabase = null; + private int lastExecutionResult = ERRNO_OK; private History history; private boolean isBeeLine = true; @@ -959,20 +960,25 @@ private int execute(ConsoleReader reader, boolean exitOnError) { // Execute one instruction; terminate on executing a script if there is an error // in silent mode, prevent the query and prompt being echoed back to terminal line = (getOpts().isSilent() && getOpts().getScriptFile() != null) ? reader - .readLine(null, ConsoleReader.NULL_MASK) : reader.readLine(getPrompt()); + .readLine(null, ConsoleReader.NULL_MASK) : reader.readLine(getPrompt()); // trim line line = (line == null) ? null : line.trim(); - if (!dispatch(line) && exitOnError) { - return ERRNO_OTHER; + if (!dispatch(line)) { + lastExecutionResult = ERRNO_OTHER; + if (exitOnError) break; + } else if (line != null) { + lastExecutionResult = ERRNO_OK; } + } catch (Throwable t) { handleException(t); return ERRNO_OTHER; } } - return ERRNO_OK; + + return lastExecutionResult; } @Override diff --git a/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java b/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java index 275036ffe9fe98de98fb7e7c6d88bff39cf879e4..d306e29f5a9b8c57182a70a1428300209c720a2b 100644 --- a/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java +++ b/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java @@ -38,6 +38,7 @@ private static final Logger LOG = LoggerFactory.getLogger(TestHiveCli.class.getName()); private static final int ERRNO_OK = 0; private static final int ERRNO_ARGS = 1; + private static final int ERRNO_OTHER = 2; private final static String SOURCE_CONTEXT = "create table if not exists test.testSrcTbl(sc1 string);"; @@ -101,7 +102,7 @@ private void verifyCMD(String CMD, String keywords, OutputStream os, String[] op @Test public void testInValidCmd() { - verifyCMD("!lss\n", "Failed to execute lss", errS, null, ERRNO_OK, true); + verifyCMD("!lss\n", "Failed to execute lss", errS, null, ERRNO_OTHER, true); } @Test @@ -159,7 +160,7 @@ public void testSourceCmd2() { public void testSourceCmd3() { File f = generateTmpFile(SOURCE_CONTEXT4); verifyCMD("source " + f.getPath() + ";" + "desc testSrcTbl4;\nquit;\n", "src", os, - new String[] { "--database", "test" }, ERRNO_OK, true); + new String[] { "--database", "test" }, ERRNO_OTHER, true); f.delete(); } @@ -205,34 +206,34 @@ public void testVariablesForSource() { @Test public void testErrOutput() { verifyCMD("show tables;set system:xxx=5;set system:yyy=${system:xxx};\nlss;", - "cannot recognize input near 'lss' '' ''", errS, null, ERRNO_OK, true); + "cannot recognize input near 'lss' '' ''", errS, null, ERRNO_OTHER, true); } @Test public void testUseCurrentDB1() { verifyCMD( "create database if not exists testDB; set hive.cli.print.current.db=true;use testDB;\n" - + "use default;drop if exists testDB;", "hive (testDB)>", os, null, ERRNO_OK, true); + + "use default;drop if exists testDB;", "hive (testDB)>", os, null, ERRNO_OTHER, true); } @Test public void testUseCurrentDB2() { verifyCMD( "create database if not exists testDB; set hive.cli.print.current.db=true;use\ntestDB;\nuse default;drop if exists testDB;", - "hive (testDB)>", os, null, ERRNO_OK, true); + "hive (testDB)>", os, null, ERRNO_OTHER, true); } @Test public void testUseCurrentDB3() { verifyCMD( "create database if not exists testDB; set hive.cli.print.current.db=true;use testDB;\n" - + "use default;drop if exists testDB;", "hive (testDB)>", os, null, ERRNO_OK, true); + + "use default;drop if exists testDB;", "hive (testDB)>", os, null, ERRNO_OTHER, true); } @Test public void testUseInvalidDB() { verifyCMD("set hive.cli.print.current.db=true;use invalidDB;", - "hive (invalidDB)>", os, null, ERRNO_OK, false); + "hive (invalidDB)>", os, null, ERRNO_OTHER, false); } @Test diff --git a/conf/hive-site.xml b/conf/hive-site.xml index dab494e4bdc783ef23a5d5bd92c32ab4ff573def..bbfdb5b76fdca5241ded59eb8efe1fef9824935d 100644 --- a/conf/hive-site.xml +++ b/conf/hive-site.xml @@ -18,5 +18,12 @@ --> - + + hive.metastore.local + false + + + hive.metastore.uris + thrift://localhost:9083 + diff --git a/service/src/java/org/apache/hive/service/servlet/QueryProfileServlet.java b/service/src/java/org/apache/hive/service/servlet/QueryProfileServlet.java index 8fa447a386c5a7a000b04453618f502e1681364e..4a33930357534fea223f058cde3abb1361dbe813 100644 --- a/service/src/java/org/apache/hive/service/servlet/QueryProfileServlet.java +++ b/service/src/java/org/apache/hive/service/servlet/QueryProfileServlet.java @@ -20,7 +20,7 @@ import org.apache.hive.service.cli.operation.OperationManager; import org.apache.hive.service.cli.operation.SQLOperationDisplay; import org.apache.hive.service.cli.session.SessionManager; -import org.apache.hive.tmpl.QueryProfileTmpl; +//import org.apache.hive.tmpl.QueryProfileTmpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,6 +52,6 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) return; } - new QueryProfileTmpl().render(response.getWriter(), sod); + //new QueryProfileTmpl().render(response.getWriter(), sod); } }