Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 897BE18E35 for ; Mon, 4 Apr 2016 22:37:52 +0000 (UTC) Received: (qmail 29584 invoked by uid 500); 4 Apr 2016 22:37:46 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 28914 invoked by uid 500); 4 Apr 2016 22:37:46 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 28327 invoked by uid 99); 4 Apr 2016 22:37:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Apr 2016 22:37:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C98E2E78B1; Mon, 4 Apr 2016 22:37:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sseth@apache.org To: commits@hive.apache.org Date: Mon, 04 Apr 2016 22:37:53 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [09/24] hive git commit: HIVE-12612: beeline always exits with 0 status when reading query from standard input (Reuben Kuhnert, reviewed by Sergio Pena) HIVE-12612: beeline always exits with 0 status when reading query from standard input (Reuben Kuhnert, reviewed by Sergio Pena) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/ac273b67 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/ac273b67 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/ac273b67 Branch: refs/heads/llap Commit: ac273b672de402027181b71fb192930645bd5cc0 Parents: 03b81bc Author: Sergio Pena Authored: Fri Apr 1 10:38:27 2016 -0500 Committer: Sergio Pena Committed: Fri Apr 1 10:38:27 2016 -0500 ---------------------------------------------------------------------- beeline/pom.xml.orig | 169 +++++++++++++++++++ .../java/org/apache/hive/beeline/BeeLine.java | 18 +- .../apache/hive/beeline/cli/TestHiveCli.java | 15 +- 3 files changed, 189 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/ac273b67/beeline/pom.xml.orig ---------------------------------------------------------------------- diff --git a/beeline/pom.xml.orig b/beeline/pom.xml.orig new file mode 100644 index 0000000..8ac83f5 --- /dev/null +++ b/beeline/pom.xml.orig @@ -0,0 +1,169 @@ + + + + 4.0.0 + + org.apache.hive + hive + 2.1.0-SNAPSHOT + ../pom.xml + + + hive-beeline + jar + Hive Beeline + + + .. + + + + + + + org.apache.hive + hive-common + ${project.version} + + + org.apache.hive + hive-metastore + ${project.version} + + + org.apache.hive + hive-shims + ${project.version} + + + org.apache.hive + hive-jdbc + ${project.version} + + + + commons-cli + commons-cli + ${commons-cli.version} + + + commons-lang + commons-lang + ${commons-lang.version} + + + commons-io + commons-io + ${commons-io.version} + + + jline + jline + ${jline.version} + + + org.apache.hadoop + hadoop-common + ${hadoop.version} + true + + + org.apache.thrift + libthrift + ${libthrift.version} + + + net.sf.supercsv + super-csv + ${super-csv.version} + + + + org.apache.hive + hive-exec + ${project.version} + tests + test + + + org.apache.hive + hive-service + ${project.version} + test + + + + org.apache.hadoop + hadoop-mapreduce-client-core + ${hadoop.version} + test + + + junit + junit + ${junit.version} + test + + + postgresql + postgresql + 9.1-901.jdbc4 + test + + + + + + sources + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + test-jar + + + + + + + + + + + ${basedir}/src/java + ${basedir}/src/test + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + + http://git-wip-us.apache.org/repos/asf/hive/blob/ac273b67/beeline/src/java/org/apache/hive/beeline/BeeLine.java ---------------------------------------------------------------------- diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java index 4ab6aa8..a4a9558 100644 --- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java +++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java @@ -953,26 +953,32 @@ public class BeeLine implements Closeable { } private int execute(ConsoleReader reader, boolean exitOnError) { - String line; + int lastExecutionResult = ERRNO_OK; while (!exit) { try { // 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 + String line = (getOpts().isSilent() && getOpts().getScriptFile() != null) ? reader .readLine(null, ConsoleReader.NULL_MASK) : reader.readLine(getPrompt()); // trim line - line = (line == null) ? null : line.trim(); + if (line != null) { + line = 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 http://git-wip-us.apache.org/repos/asf/hive/blob/ac273b67/beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java ---------------------------------------------------------------------- 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 275036f..d306e29 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 @@ public class TestHiveCli { 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 @@ public class TestHiveCli { @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 class TestHiveCli { 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 class TestHiveCli { @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