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 1593135  [ZEPPELIN-5169] Hive set statement doesn't work for some hive 
version when there's empty line ahead
1593135 is described below

commit 15931357a05f02d2f035668c685aa569836cea65
Author: Jeff Zhang <[email protected]>
AuthorDate: Wed Dec 23 09:48:45 2020 +0800

    [ZEPPELIN-5169] Hive set statement doesn't work for some hive version when 
there's empty line ahead
    
    ### What is this PR for?
    
    The current sql split logic will append empty lines before sql statement, 
this would cause issues for the sql statement for some hive version. This is to 
fix it by checking whether it is set statement, if yes, then trim the sql 
statement.
    
    ### What type of PR is it?
    [ Improvement ]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-5169
    
    ### 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 <[email protected]>
    
    Closes #4005 from zjffdu/ZEPPELIN-5169 and squashes the following commits:
    
    b05b0636b [Jeff Zhang] [ZEPPELIN-5169]. Hive set statement doesn't work for 
some hive version when there's empty line ahead
    
    (cherry picked from commit e96c244b3ba5bc391481b2725d0b2c67d450dfc6)
    Signed-off-by: Jeff Zhang <[email protected]>
---
 jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java | 5 +++++
 1 file changed, 5 insertions(+)

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 d63358b..2b29ece 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@@ -717,6 +717,11 @@ public class JDBCInterpreter extends KerberosInterpreter {
       List<String>  sqlArray = sqlSplitter.splitSql(sql);
       for (String sqlToExecute : sqlArray) {
         LOGGER.info("Execute sql: " + sqlToExecute);
+        if (sqlToExecute.trim().toLowerCase().startsWith("set ")) {
+          // 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();
+        }
         statement = connection.createStatement();
 
         // fetch n+1 rows in order to indicate there's more rows available 
(for large selects)

Reply via email to