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 a8e7b96  [ZEPPELIN-4217]. Remove semicolon at the end of sql statement 
for JdbcInterpreter
a8e7b96 is described below

commit a8e7b961756e83bf8b193754da8bf2e9c6f14c80
Author: Jeff Zhang <zjf...@apache.org>
AuthorDate: Fri Jul 5 16:13:48 2019 +0800

    [ZEPPELIN-4217]. Remove semicolon at the end of sql statement for 
JdbcInterpreter
    
    ### What is this PR for?
    It is very possible for user to add semicolon at the end of sql statement. 
Some jdbc engine will handle the semicolon for users, while others won't, e.g. 
hive. This PR will remove the semicolon at the end of sql.
    
    ### What type of PR is it?
    [Bug Fix]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    * https://jira.apache.org/jira/browse/ZEPPELIN-4217
    
    ### How should this be tested?
    * CI pass
    
    ### 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 <zjf...@apache.org>
    
    Closes #3400 from zjffdu/ZEPPELIN-4217 and squashes the following commits:
    
    3142c6ad5 [Jeff Zhang] [ZEPPELIN-4217]. Remove semicolon at the end of sql 
statement for JdbcInterpreter
---
 jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java     | 4 ++++
 jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java | 4 ++--
 2 files 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 000b46f..0d1f087 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@@ -710,9 +710,13 @@ public class JDBCInterpreter extends KerberosInterpreter {
 
     try {
       List<String> sqlArray;
+      sql = sql.trim();
       if (splitQuery) {
         sqlArray = splitSqlQueries(sql);
       } else {
+        if (sql.endsWith(";")) {
+          sql = sql.substring(0, sql.length() - 1);
+        }
         sqlArray = Arrays.asList(sql);
       }
 
diff --git 
a/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java 
b/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java
index c7d417d..e08f071 100644
--- a/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java
+++ b/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java
@@ -181,7 +181,7 @@ public class JDBCInterpreterTest extends 
BasicJDBCTestCaseAdapter {
     JDBCInterpreter t = new JDBCInterpreter(properties);
     t.open();
 
-    String sqlQuery = "select * from test_table WHERE ID in ('a', 'b')";
+    String sqlQuery = "select * from test_table WHERE ID in ('a', 'b'); ";
 
     InterpreterResult interpreterResult = t.interpret(sqlQuery, 
interpreterContext);
 
@@ -229,7 +229,7 @@ public class JDBCInterpreterTest extends 
BasicJDBCTestCaseAdapter {
         "select '\\', ';';" +
         "select '''', ';';" +
         "select /*+ scan */ * from test_table;" +
-        "--singleLineComment\nselect * from test_table";
+        "--singleLineComment\nselect * from test_table;";
 
 
     Properties properties = new Properties();

Reply via email to