ZEPPELIN-2241: JDBC interpreter throws npe on connecting to any db that has a 
schema with "null" name

A few sentences describing the overall goals of the pull request's commits.
First time? Check out the contributing guide - 
https://zeppelin.apache.org/contribution/contributions.html

Prevents JDBC interpreter from throwing a stacktrace when the database has a 
schema with no name (null).

[Bug Fix]

* [ ] - Task

* Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/
* Put link here, and add [ZEPPELIN-*Jira number*] in PR title, eg. 
[ZEPPELIN-533]

https://issues.apache.org/jira/browse/ZEPPELIN-2241

Outline the steps to test the PR here.

Use JDBC interpreter to connect to any database that has a schema without a 
name. Apache Phoenix in particular has such a schema by default.

* Does the licenses files need update?

No

* Is there breaking changes for older versions?

No

* Does this needs documentation?

No

Author: Randy Gelhausen <rgel...@gmail.com>

Closes #2117 from randerzander/master and squashes the following commits:

49d33f9 [Randy Gelhausen] Removing comment per feedback
79d8a23 [Randy Gelhausen] Added comment to the change
0101296 [Randy Gelhausen] ZEPPELIN-2241: JDBC interpreter throws npe on 
connecting to any db that has a schema with "null" name

(cherry picked from commit 623b4ace9e5c8f1667bd34c21b944b9d4636a2bd)
Signed-off-by: Lee moon soo <m...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/b00e27c7
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/b00e27c7
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/b00e27c7

Branch: refs/heads/branch-0.7
Commit: b00e27c732dd0ad9ca9bbbfab2d6c61ca105917f
Parents: bfa812a
Author: Randy Gelhausen <rgel...@gmail.com>
Authored: Mon Mar 13 12:46:47 2017 -0400
Committer: Lee moon soo <m...@apache.org>
Committed: Wed Mar 15 08:22:36 2017 -0700

----------------------------------------------------------------------
 jdbc/src/main/java/org/apache/zeppelin/jdbc/SqlCompleter.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b00e27c7/jdbc/src/main/java/org/apache/zeppelin/jdbc/SqlCompleter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/SqlCompleter.java 
b/jdbc/src/main/java/org/apache/zeppelin/jdbc/SqlCompleter.java
index e5c8987..f282992 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/SqlCompleter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/SqlCompleter.java
@@ -217,6 +217,8 @@ public class SqlCompleter extends StringsCompleter {
       try {
         while (schemas.next()) {
           String schemaName = schemas.getString("TABLE_SCHEM");
+          if (schemaName == null)
+            schemaName = "";
           if (!isBlank(schemaName)) {
             names.add(schemaName + ".");
           }

Reply via email to