You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by sz...@apache.org on 2015/05/04 02:13:25 UTC
hive git commit: HIVE-10541 : Beeline requires newline at the end of
each query in a file (Chaoyu Tang, reviewed by Thejas)
Repository: hive
Updated Branches:
refs/heads/master 8eb0ede82 -> 247883354
HIVE-10541 : Beeline requires newline at the end of each query in a file (Chaoyu Tang, reviewed by Thejas)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/24788335
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/24788335
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/24788335
Branch: refs/heads/master
Commit: 2478833548c3fd7899ec69b6e9305498831b9d5d
Parents: 8eb0ede
Author: Szehon Ho <sz...@cloudera.com>
Authored: Sun May 3 17:12:54 2015 -0700
Committer: Szehon Ho <sz...@cloudera.com>
Committed: Sun May 3 17:12:54 2015 -0700
----------------------------------------------------------------------
beeline/src/java/org/apache/hive/beeline/BeeLine.java | 7 ++++++-
.../org/apache/hive/beeline/TestBeeLineWithArgs.java | 12 ++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/24788335/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 b3d89cb..e207670 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
@@ -31,6 +31,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.io.SequenceInputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -829,7 +830,11 @@ public class BeeLine implements Closeable {
public ConsoleReader getConsoleReader(InputStream inputStream) throws IOException {
if (inputStream != null) {
// ### NOTE: fix for sf.net bug 879425.
- consoleReader = new ConsoleReader(inputStream, getOutputStream());
+ // Working around an issue in jline-2.1.2, see https://github.com/jline/jline/issues/10
+ // by appending a newline to the end of inputstream
+ InputStream inputStreamAppendedNewline = new SequenceInputStream(inputStream,
+ new ByteArrayInputStream((new String("\n")).getBytes()));
+ consoleReader = new ConsoleReader(inputStreamAppendedNewline, getOutputStream());
} else {
consoleReader = new ConsoleReader();
}
http://git-wip-us.apache.org/repos/asf/hive/blob/24788335/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java b/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java
index f66229f..f0795d2 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java
@@ -220,6 +220,18 @@ public class TestBeeLineWithArgs {
}
/**
+ * Fix to HIVE-10541: Beeline requires a newline at the end of each query in a file.
+ * Otherwise, the last line of cmd in the script will be ignored.
+ */
+ @Test
+ public void testLastLineCmdInScriptFile() throws Throwable {
+ final String SCRIPT_TEXT = "show databases;\nshow tables;";
+ final String EXPECTED_PATTERN = " testbeelinetable1 ";
+ List<String> argList = getBaseArgs(miniHS2.getBaseJdbcURL());
+ testScriptFile( SCRIPT_TEXT, EXPECTED_PATTERN, true, argList);
+ }
+
+ /**
* Test Beeline -hivevar option. User can specify --hivevar name=value on Beeline command line.
* In the script, user should be able to use it in the form of ${name}, which will be substituted with
* the value.