hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khorg...@apache.org
Subject [2/2] hive git commit: HIVE-10659 : Beeline command which contains semi-colon as a non-command terminator will fail (Hari Subramaniyan via Sushanth Sowmyan)
Date Wed, 20 May 2015 22:28:56 GMT
HIVE-10659 : Beeline command which contains semi-colon as a non-command terminator will fail
(Hari Subramaniyan via Sushanth Sowmyan)


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

Branch: refs/heads/master
Commit: 4eed1add28dbce2447ed65beedc841572b006b73
Parents: 1fd46cd
Author: Sushanth Sowmyan <khorgath@gmail.com>
Authored: Wed May 20 15:24:02 2015 -0700
Committer: Sushanth Sowmyan <khorgath@gmail.com>
Committed: Wed May 20 15:28:49 2015 -0700

----------------------------------------------------------------------
 .../src/java/org/apache/hive/beeline/BeeLine.java |  2 +-
 .../java/org/apache/hive/beeline/BeeLineOpts.java |  9 +++++++++
 .../java/org/apache/hive/beeline/Commands.java    | 18 ++++++++++++++----
 .../org/apache/hive/beeline/HiveSchemaHelper.java |  1 -
 .../org/apache/hive/beeline/HiveSchemaTool.java   |  3 +++
 5 files changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/4eed1add/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 0da15f6..8928c0c 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
@@ -976,7 +976,7 @@ public class BeeLine implements Closeable {
       return cmdMap.values().iterator().next()
           .execute(line);
     } else {
-      return commands.sql(line);
+      return commands.sql(line, getOpts().getEntireLineAsCommand());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/4eed1add/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java
----------------------------------------------------------------------
diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java b/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java
index 649bb63..c1ec82a 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java
@@ -69,6 +69,7 @@ class BeeLineOpts implements Completer {
   private boolean showWarnings = false;
   private boolean showNestedErrs = false;
   private boolean showElapsedTime = true;
+  private boolean entireLineAsCommand = false;
   private String numberFormat = "default";
   private final Terminal terminal = TerminalFactory.get();
   private int maxWidth = DEFAULT_MAX_WIDTH;
@@ -345,6 +346,14 @@ class BeeLineOpts implements Completer {
     return isolation;
   }
 
+  public void setEntireLineAsCommand(boolean entireLineAsCommand) {
+    this.entireLineAsCommand = entireLineAsCommand;
+  }
+
+  public boolean getEntireLineAsCommand() {
+    return entireLineAsCommand;
+  }
+
   public void setHistoryFile(String historyFile) {
     this.historyFile = historyFile;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/4eed1add/beeline/src/java/org/apache/hive/beeline/Commands.java
----------------------------------------------------------------------
diff --git a/beeline/src/java/org/apache/hive/beeline/Commands.java b/beeline/src/java/org/apache/hive/beeline/Commands.java
index 4c60525..903849c 100644
--- a/beeline/src/java/org/apache/hive/beeline/Commands.java
+++ b/beeline/src/java/org/apache/hive/beeline/Commands.java
@@ -706,7 +706,11 @@ public class Commands {
   }
 
   public boolean sql(String line) {
-    return execute(line, false);
+    return execute(line, false, false);
+  }
+
+  public boolean sql(String line, boolean entireLineAsCommand) {
+    return execute(line, false, entireLineAsCommand);
   }
 
   public boolean sh(String line) {
@@ -740,10 +744,10 @@ public class Commands {
   }
 
   public boolean call(String line) {
-    return execute(line, true);
+    return execute(line, true, false);
   }
 
-  private boolean execute(String line, boolean call) {
+  private boolean execute(String line, boolean call, boolean entireLineAsCommand) {
     if (line == null || line.length() == 0) {
       return false; // ???
     }
@@ -792,7 +796,13 @@ public class Commands {
     }
 
     line = line.trim();
-    String[] cmds = line.split(";");
+    String[] cmds;
+    if (entireLineAsCommand) {
+      cmds = new String[1];
+      cmds[0] = line;
+    } else {
+      cmds = line.split(";");
+    }
     for (int i = 0; i < cmds.length; i++) {
       String sql = cmds[i].trim();
       if (sql.length() != 0) {

http://git-wip-us.apache.org/repos/asf/hive/blob/4eed1add/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java
----------------------------------------------------------------------
diff --git a/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java b/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java
index 58760d8..a6b11ba 100644
--- a/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java
+++ b/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java
@@ -248,7 +248,6 @@ public class HiveSchemaHelper {
         // if this is a valid executable command then add it to the buffer
         if (!isNonExecCommand(currentCommand)) {
           currentCommand = cleanseCommand(currentCommand);
-
           if (isNestedScript(currentCommand)) {
             // if this is a nested sql script then flatten it
             String currScript = getScriptName(currentCommand);

http://git-wip-us.apache.org/repos/asf/hive/blob/4eed1add/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java
----------------------------------------------------------------------
diff --git a/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java b/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java
index 409126e..2477e5f 100644
--- a/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java
+++ b/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java
@@ -350,6 +350,9 @@ public class HiveSchemaTool {
     }
     beeLine.getOpts().setAllowMultiLineCommand(false);
     beeLine.getOpts().setIsolation("TRANSACTION_READ_COMMITTED");
+    // We can be pretty sure that an entire line can be processed as a single command since
+    // we always add a line separator at the end while calling dbCommandParser.buildCommand.
+    beeLine.getOpts().setEntireLineAsCommand(true);
     int status = beeLine.begin(argList.toArray(new String[0]), null);
     if (status != 0) {
       throw new IOException("Schema script failed, errorcode " + status);


Mime
View raw message