hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pv...@apache.org
Subject hive git commit: HIVE-17050: Multiline queries that have comment in middle fail when executed via "beeline -e" (Yibing Shi reviewed by Yongzhi Chen and Peter Vary)
Date Fri, 28 Jul 2017 09:04:59 GMT
Repository: hive
Updated Branches:
  refs/heads/master 52a64f14d -> 705979e68


HIVE-17050: Multiline queries that have comment in middle fail when executed via "beeline
-e" (Yibing Shi reviewed by Yongzhi Chen and Peter Vary)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/705979e6
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/705979e6
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/705979e6

Branch: refs/heads/master
Commit: 705979e687bda7c21ae80e8c169acaf48a7239d5
Parents: 52a64f1
Author: Peter Vary <pvary@cloudera.com>
Authored: Fri Jul 28 11:03:11 2017 +0200
Committer: Peter Vary <pvary@cloudera.com>
Committed: Fri Jul 28 11:03:11 2017 +0200

----------------------------------------------------------------------
 .../apache/hive/common/util/HiveStringUtils.java   | 10 +++++++---
 .../test/queries/clientpositive/cmdwithcomments.q  |  2 ++
 .../results/clientpositive/cmdwithcomments.q.out   | 17 ++++++++++++++---
 3 files changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/705979e6/common/src/java/org/apache/hive/common/util/HiveStringUtils.java
----------------------------------------------------------------------
diff --git a/common/src/java/org/apache/hive/common/util/HiveStringUtils.java b/common/src/java/org/apache/hive/common/util/HiveStringUtils.java
index 71d11bd..aac3a53 100644
--- a/common/src/java/org/apache/hive/common/util/HiveStringUtils.java
+++ b/common/src/java/org/apache/hive/common/util/HiveStringUtils.java
@@ -1117,10 +1117,13 @@ public class HiveStringUtils {
       return "";  //assume # can only be used at the beginning of line.
     }
     StringBuilder builder = new StringBuilder();
-    for (int index = 0; index < line.length(); index++) {
+    for (int index = 0; index < line.length();) {
       if (startQuote[0] == -1 && index < line.length() - 1 && line.charAt(index)
== '-'
           && line.charAt(index + 1) == '-') {
-        return builder.toString().trim();
+        // Jump to the end of current line. When a multiple line query is executed with -e
parameter,
+        // it is passed in as one line string separated with '\n'
+        for (; index < line.length() && line.charAt(index) != '\n'; ++index);
+        continue;
       }
 
       char letter = line.charAt(index);
@@ -1132,9 +1135,10 @@ public class HiveStringUtils {
       }
 
       builder.append(letter);
+      index++;
     }
 
-    return builder.toString();
+    return builder.toString().trim();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hive/blob/705979e6/ql/src/test/queries/clientpositive/cmdwithcomments.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cmdwithcomments.q b/ql/src/test/queries/clientpositive/cmdwithcomments.q
index e9c0d43..4c2963e 100644
--- a/ql/src/test/queries/clientpositive/cmdwithcomments.q
+++ b/ql/src/test/queries/clientpositive/cmdwithcomments.q
@@ -10,4 +10,6 @@ limit 1;
 --comment7
 select "this is
 another --string value" from numt where idx =2; --comment8
+select 1, --comment
+2;
 drop table numt;

http://git-wip-us.apache.org/repos/asf/hive/blob/705979e6/ql/src/test/results/clientpositive/cmdwithcomments.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cmdwithcomments.q.out b/ql/src/test/results/clientpositive/cmdwithcomments.q.out
index 93c9431..151a82c 100644
--- a/ql/src/test/results/clientpositive/cmdwithcomments.q.out
+++ b/ql/src/test/results/clientpositive/cmdwithcomments.q.out
@@ -63,12 +63,23 @@ POSTHOOK: Input: default@numt
 this is
 another --string value
 PREHOOK: query: --comment8
-drop table numt
+select 1, --comment
+2
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: --comment8
+select 1, --comment
+2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+1	2
+PREHOOK: query: drop table numt
 PREHOOK: type: DROPTABLE
 PREHOOK: Input: default@numt
 PREHOOK: Output: default@numt
-POSTHOOK: query: --comment8
-drop table numt
+POSTHOOK: query: drop table numt
 POSTHOOK: type: DROPTABLE
 POSTHOOK: Input: default@numt
 POSTHOOK: Output: default@numt


Mime
View raw message