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

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


The following commit(s) were added to refs/heads/master by this push:
     new e96c244  [ZEPPELIN-5169] Hive set statement doesn't work for some hive 
version when there's empty line ahead
e96c244 is described below

commit e96c244b3ba5bc391481b2725d0b2c67d450dfc6
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
---
 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 1ff77f2..7709443 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@@ -721,6 +721,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