You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by sp...@apache.org on 2016/04/01 17:40:41 UTC
hive git commit: HIVE-12612: beeline always exits with 0 status when
reading query from standard input (Reuben Kuhnert, reviewed by Sergio Pena)
Repository: hive
Updated Branches:
refs/heads/master 03b81bc9c -> ac273b672
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/master
Commit: ac273b672de402027181b71fb192930645bd5cc0
Parents: 03b81bc
Author: Sergio Pena <se...@cloudera.com>
Authored: Fri Apr 1 10:38:27 2016 -0500
Committer: Sergio Pena <se...@cloudera.com>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.hive</groupId>
+ <artifactId>hive</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>hive-beeline</artifactId>
+ <packaging>jar</packaging>
+ <name>Hive Beeline</name>
+
+ <properties>
+ <hive.path.to.root>..</hive.path.to.root>
+ </properties>
+
+ <dependencies>
+ <!-- dependencies are always listed in sorted order by groupId, artifectId -->
+ <!-- intra-project -->
+ <dependency>
+ <groupId>org.apache.hive</groupId>
+ <artifactId>hive-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hive</groupId>
+ <artifactId>hive-metastore</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hive</groupId>
+ <artifactId>hive-shims</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hive</groupId>
+ <artifactId>hive-jdbc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- inter-project -->
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>${commons-cli.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>${commons-lang.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>${commons-io.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>${jline.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-common</artifactId>
+ <version>${hadoop.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.thrift</groupId>
+ <artifactId>libthrift</artifactId>
+ <version>${libthrift.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.supercsv</groupId>
+ <artifactId>super-csv</artifactId>
+ <version>${super-csv.version}</version>
+ </dependency>
+ <!-- test intra-project -->
+ <dependency>
+ <groupId>org.apache.hive</groupId>
+ <artifactId>hive-exec</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hive</groupId>
+ <artifactId>hive-service</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- test inter-project -->
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-mapreduce-client-core</artifactId>
+ <version>${hadoop.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>9.1-901.jdbc4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>sources</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+ <sourceDirectory>${basedir}/src/java</sourceDirectory>
+ <testSourceDirectory>${basedir}/src/test</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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' '<EOF>' '<EOF>'", errS, null, ERRNO_OK, true);
+ "cannot recognize input near 'lss' '<EOF>' '<EOF>'", 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