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 80ac506 [ZEPPELIN-5311] Unable to run list & add hive statement
80ac506 is described below
commit 80ac50649dde5e68bc7fb1456bae0fea5ffa8e2d
Author: Jeff Zhang <[email protected]>
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 <[email protected]>
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
---
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 4fe7b87..62ffd67 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@@ -727,12 +727,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)