You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by vi...@apache.org on 2018/03/30 22:02:50 UTC
hive git commit: HIVE-19047 : Only the first init file is interpreted
(Bharathkrishna Guruvayoor Murali reviewed by Zoltan Haindrich and Vihang
Karajgaonkar)
Repository: hive
Updated Branches:
refs/heads/master 52290e72b -> 510960268
HIVE-19047 : Only the first init file is interpreted (Bharathkrishna Guruvayoor Murali reviewed by Zoltan Haindrich and Vihang Karajgaonkar)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/51096026
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/51096026
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/51096026
Branch: refs/heads/master
Commit: 510960268f19f4a5cbc1714af1f6822e6d26a855
Parents: 52290e7
Author: Bharathkrishna Guruvayoor Murali <bh...@cloudera.com>
Authored: Fri Mar 30 14:53:58 2018 -0700
Committer: Vihang Karajgaonkar <vi...@cloudera.com>
Committed: Fri Mar 30 14:53:58 2018 -0700
----------------------------------------------------------------------
.../java/org/apache/hive/beeline/BeeLine.java | 20 ++++++++++++++++----
.../hive/beeline/TestBeelineArgParsing.java | 13 +++++++++++++
2 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/51096026/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 c6d009c..4928761 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
@@ -357,7 +357,7 @@ public class BeeLine implements Closeable {
// -i <init file>
options.addOption(OptionBuilder
- .hasArg()
+ .hasArgs()
.withArgName("init")
.withDescription("script file for initialization")
.create('i'));
@@ -1120,18 +1120,30 @@ public class BeeLine implements Closeable {
}
int runInit() {
- String initFiles[] = getOpts().getInitFiles();
+ String[] initFiles = getOpts().getInitFiles();
+
+ //executionResult will be ERRNO_OK only if all initFiles execute successfully
+ int executionResult = ERRNO_OK;
+ boolean exitOnError = !getOpts().getForce();
+
if (initFiles != null && initFiles.length != 0) {
for (String initFile : initFiles) {
info("Running init script " + initFile);
try {
- return executeFile(initFile);
+ int currentResult = executeFile(initFile);
+ if (currentResult != ERRNO_OK) {
+ executionResult = currentResult;
+
+ if (exitOnError) {
+ return executionResult;
+ }
+ }
} finally {
exit = false;
}
}
}
- return ERRNO_OK;
+ return executionResult;
}
private int embeddedConnect() {
http://git-wip-us.apache.org/repos/asf/hive/blob/51096026/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
----------------------------------------------------------------------
diff --git a/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java b/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
index 40dbc22..1fa6a75 100644
--- a/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
+++ b/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
@@ -255,6 +255,19 @@ public class TestBeelineArgParsing {
}
/**
+ * Test beeline with multiple initfiles in -i.
+ */
+ @Test
+ public void testMultipleInitFiles() {
+ TestBeeline bl = new TestBeeline();
+ String[] args = new String[] {"-i", "/url/to/file1", "-i", "/url/to/file2"};
+ Assert.assertEquals(0, bl.initArgs(args));
+ String[] files = bl.getOpts().getInitFiles();
+ Assert.assertEquals("/url/to/file1", files[0]);
+ Assert.assertEquals("/url/to/file2", files[1]);
+ }
+
+ /**
* Displays the usage.
*/
@Test