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 2020/10/29 02:03:29 UTC
[zeppelin] branch master updated: [ZEPPELIN-5103]. Simply jdbc
interpreter error message
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 6981c4d [ZEPPELIN-5103]. Simply jdbc interpreter error message
6981c4d is described below
commit 6981c4dd74c222f87c38fe4a266b3f84768a5049
Author: Jeff Zhang <zj...@apache.org>
AuthorDate: Fri Oct 23 11:11:06 2020 +0800
[ZEPPELIN-5103]. Simply jdbc interpreter error message
### What is this PR for?
In this PR, I would only print exception message when it is SQLException, otherwise would print the full stacktrace, because in this case it is most likely due to jdbc interpreter's internal error.
### What type of PR is it?
[Improvement]
### Todos
* [ ] - Task
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-5103
### How should this be tested?
* CI pass
### Screenshots (if appropriate)
![image](https://user-images.githubusercontent.com/164491/96952163-c0a35b00-1520-11eb-9bcf-c7355a151184.png)
### 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 #3952 from zjffdu/ZEPPELIN-5103 and squashes the following commits:
4001e1b84 [Jeff Zhang] [ZEPPELIN-5103]. Simply jdbc interpreter error message
---
.../java/org/apache/zeppelin/jdbc/JDBCInterpreter.java | 17 ++++++++++-------
.../apache/zeppelin/python/IPythonInterpreterTest.java | 2 +-
2 files changed, 11 insertions(+), 8 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 76d4d20..f54f5b5 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@@ -706,18 +706,17 @@ public class JDBCInterpreter extends KerberosInterpreter {
try {
connection = getConnection(dbPrefix, context);
} catch (Exception e) {
- String errorMsg = ExceptionUtils.getStackTrace(e);
+ LOGGER.error("Fail to getConnection", e);
try {
closeDBPool(user, dbPrefix);
} catch (SQLException e1) {
LOGGER.error("Cannot close DBPool for user, dbPrefix: " + user + dbPrefix, e1);
}
- try {
- context.out.write(errorMsg);
- } catch (IOException ex) {
- throw new InterpreterException("Fail to write output", ex);
+ if (e instanceof SQLException) {
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ } else {
+ return new InterpreterResult(Code.ERROR, ExceptionUtils.getStackTrace(e));
}
- return new InterpreterResult(Code.ERROR);
}
if (connection == null) {
return new InterpreterResult(Code.ERROR, "Prefix not found.");
@@ -806,7 +805,11 @@ public class JDBCInterpreter extends KerberosInterpreter {
}
} catch (Throwable e) {
LOGGER.error("Cannot run " + sql, e);
- return new InterpreterResult(Code.ERROR, ExceptionUtils.getStackTrace(e));
+ if (e instanceof SQLException) {
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ } else {
+ return new InterpreterResult(Code.ERROR, ExceptionUtils.getStackTrace(e));
+ }
} finally {
//In case user ran an insert/update/upsert statement
if (connection != null) {
diff --git a/python/src/test/java/org/apache/zeppelin/python/IPythonInterpreterTest.java b/python/src/test/java/org/apache/zeppelin/python/IPythonInterpreterTest.java
index c2d8ae3..08e0c8d 100644
--- a/python/src/test/java/org/apache/zeppelin/python/IPythonInterpreterTest.java
+++ b/python/src/test/java/org/apache/zeppelin/python/IPythonInterpreterTest.java
@@ -298,7 +298,7 @@ public class IPythonInterpreterTest extends BasePythonInterpreterTest {
assertEquals(context.out.toInterpreterResultMessage().get(0).getData(),
InterpreterResult.Code.SUCCESS, result.code());
interpreterResultMessages = context.out.toInterpreterResultMessage();
-
+
assertEquals(context.out.toString(), 5, interpreterResultMessages.size());
// the first message is the warning text message.
assertEquals(InterpreterResult.Type.HTML, interpreterResultMessages.get(1).getType());