You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2021/06/24 07:40:57 UTC

[zeppelin] branch branch-0.9 updated: [ZEPPELIN-5311] Unable to run list & add hive statement

This is an automated email from the ASF dual-hosted git repository.

zjffdu pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/branch-0.9 by this push:
     new cc332e4  [ZEPPELIN-5311] Unable to run list & add hive statement
cc332e4 is described below

commit cc332e4acd4f3780e1957e87d70456a7ba0545f7
Author: Jeff Zhang <zj...@apache.org>
AuthorDate: Wed Jun 23 23:59:45 2021 +0800

    [ZEPPELIN-5311] Unable to run list & add hive statement
    
    ### What is this PR for?
    
    Trivial PR to support list & add hive statement as well, just trim the whitespace otherwise hive will throw syntax error exception.
    
    ### What type of PR is it?
    [Improvement ]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-5311
    
    ### How should this be tested?
    * Manually tested
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: Jeff Zhang <zj...@apache.org>
    
    Closes #4143 from zjffdu/ZEPPELIN-5311 and squashes the following commits:
    
    9d08aecefd [Jeff Zhang] address comment
    b3c8bae937 [Jeff Zhang] [ZEPPELIN-5311] Unable to run list & add hive statement
    
    (cherry picked from commit 80ac50649dde5e68bc7fb1456bae0fea5ffa8e2d)
    Signed-off-by: Jeff Zhang <zj...@apache.org>
---
 jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
index 85d771e..1936259 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@@ -723,12 +723,16 @@ public class JDBCInterpreter extends KerberosInterpreter {
     try {
       List<String>  sqlArray = sqlSplitter.splitSql(sql);
       for (String sqlToExecute : sqlArray) {
-        LOGGER.info("Execute sql: " + sqlToExecute);
-        if (sqlToExecute.trim().toLowerCase().startsWith("set ")) {
+        String sqlTrimmedLowerCase = sqlToExecute.trim().toLowerCase();
+        if (sqlTrimmedLowerCase.startsWith("set ") ||
+                sqlTrimmedLowerCase.startsWith("list ") ||
+                sqlTrimmedLowerCase.startsWith("add ") ||
+                sqlTrimmedLowerCase.startsWith("delete ")) {
           // some version of hive doesn't work with set statement with empty line ahead.
           // so we need to trim it first in this case.
           sqlToExecute = sqlToExecute.trim();
         }
+        LOGGER.info("Execute sql: " + sqlToExecute);
         statement = connection.createStatement();
 
         // fetch n+1 rows in order to indicate there's more rows available (for large selects)