You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2016/01/27 17:50:36 UTC
hive git commit: HIVE-12789 : Fix output twice in the history command
of Beeline (Shinichi Yamashita via Ashutosh Chauhan)
Repository: hive
Updated Branches:
refs/heads/master 7981904fa -> ef2db2122
HIVE-12789 : Fix output twice in the history command of Beeline (Shinichi Yamashita via Ashutosh Chauhan)
Signed-off-by: Ashutosh Chauhan <ha...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/ef2db212
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/ef2db212
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/ef2db212
Branch: refs/heads/master
Commit: ef2db2122dfde3b284d6d9d395dcf654cdbaffb4
Parents: 7981904
Author: Shinichi Yamashita <ya...@oss.nttdata.co.jp>
Authored: Thu Jan 7 04:52:00 2016 -0800
Committer: Ashutosh Chauhan <ha...@apache.org>
Committed: Wed Jan 27 08:50:10 2016 -0800
----------------------------------------------------------------------
.../java/org/apache/hive/beeline/BeeLine.java | 5 +-
.../apache/hive/beeline/TestBeeLineHistory.java | 66 ++++++++++++++++++++
2 files changed, 67 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/ef2db212/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 f7399bc..4ab6aa8 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
@@ -1031,10 +1031,7 @@ public class BeeLine implements Closeable {
// now load in the previous history
if (hist != null) {
History h = consoleReader.getHistory();
- if (h instanceof FileHistory) {
- ((FileHistory) consoleReader.getHistory()).load(new ByteArrayInputStream(hist
- .toByteArray()));
- } else {
+ if (!(h instanceof FileHistory)) {
consoleReader.getHistory().add(hist.toString());
}
}
http://git-wip-us.apache.org/repos/asf/hive/blob/ef2db212/beeline/src/test/org/apache/hive/beeline/TestBeeLineHistory.java
----------------------------------------------------------------------
diff --git a/beeline/src/test/org/apache/hive/beeline/TestBeeLineHistory.java b/beeline/src/test/org/apache/hive/beeline/TestBeeLineHistory.java
new file mode 100644
index 0000000..91e812f
--- /dev/null
+++ b/beeline/src/test/org/apache/hive/beeline/TestBeeLineHistory.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.hive.beeline;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * TestBeeLineHistory - executes tests of the !history command of BeeLine
+ */
+public class TestBeeLineHistory {
+
+ private static final String fileName = "history";
+
+ @BeforeClass
+ public static void beforeTests() throws Exception {
+ PrintWriter writer = new PrintWriter(fileName);
+ writer.println("select 1;");
+ writer.println("select 2;");
+ writer.close();
+ }
+
+ @Test
+ public void testNumHistories() throws Exception {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ PrintStream ops = new PrintStream(os);
+ BeeLine beeline = new BeeLine();
+ beeline.getOpts().setHistoryFile(fileName);
+ beeline.setOutputStream(ops);
+ beeline.getConsoleReader(null);
+ beeline.dispatch("!history");
+ String output = os.toString("UTF-8");
+ int numHistories = output.split("\n").length;
+ Assert.assertEquals(numHistories, 2);
+ beeline.close();
+ }
+
+ @AfterClass
+ public static void afterTests() throws Exception {
+ File file = new File(fileName);
+ file.delete();
+ }
+}