zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjf...@apache.org
Subject zeppelin git commit: [ZEPPELIN-3656] Fix for completion with Livy interpreter
Date Wed, 25 Jul 2018 09:35:10 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master d49dcc251 -> 8769d41ad


[ZEPPELIN-3656] Fix for completion with Livy interpreter

### What is this PR for?
Fix for NullPointerException when using code completion in the Livy Interpreter when Shared
Interpreter is enabled.

### What type of PR is it?
Bug Fix

### What is the Jira issue?
[ZEPPELIN-3656](https://issues.apache.org/jira/browse/ZEPPELIN-3656)

### How should this be tested?
Run Livy Interpreter in an environment where Shared Interpreter is enabled and attempt to
trigger code completions.

A unit test has been added to test the completion API when using a shared interpreter. Before
applying the fix this test was failing with the same NPE.

### 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: Alex Bush <alex.bush@coxauto.co.uk>

Closes #3094 from alexjbush/ZEPPELIN-3656 and squashes the following commits:

4f4a875bf [Alex Bush] Correct completion test
cd0c2133f [Alex Bush] Force a failing test
71562e0f1 [Alex Bush] Test IT for Changes
32aa7c567 [Alex Bush] [ZEPPELIN-3656] Fix for completion with Livy interpreter


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

Branch: refs/heads/master
Commit: 8769d41ad568155d67b5013c5e4ebe453e19190e
Parents: d49dcc2
Author: Alex Bush <alex.bush@coxauto.co.uk>
Authored: Tue Jul 24 17:08:22 2018 +0100
Committer: Jeff Zhang <zjffdu@apache.org>
Committed: Wed Jul 25 17:35:04 2018 +0800

----------------------------------------------------------------------
 .../java/org/apache/zeppelin/livy/BaseLivyInterpreter.java   | 4 ++--
 .../java/org/apache/zeppelin/livy/LivyInterpreterIT.java     | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8769d41a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java
----------------------------------------------------------------------
diff --git a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java
index 1ecb154..95674ea 100644
--- a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java
+++ b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java
@@ -248,7 +248,7 @@ public abstract class BaseLivyInterpreter extends Interpreter {
       candidates = callCompletion(new CompletionRequest(buf, getSessionKind(), cursor));
     } catch (SessionNotFoundException e) {
       LOGGER.warn("Livy session {} is expired. Will return empty list of candidates.",
-          sessionInfo.id);
+          getSessionInfo().id);
     } catch (LivyException le) {
       logger.error("Failed to call code completions. Will return empty list of candidates",
le);
     }
@@ -259,7 +259,7 @@ public abstract class BaseLivyInterpreter extends Interpreter {
     List<InterpreterCompletion> candidates = new ArrayList<>();
     try {
       CompletionResponse resp = CompletionResponse.fromJson(
-          callRestAPI("/sessions/" + sessionInfo.id + "/completion", "POST", req.toJson()));
+          callRestAPI("/sessions/" + getSessionInfo().id + "/completion", "POST", req.toJson()));
       for (String candidate : resp.candidates) {
         candidates.add(new InterpreterCompletion(candidate, candidate, StringUtils.EMPTY));
       }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8769d41a/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
----------------------------------------------------------------------
diff --git a/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java b/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
index 4357bb8..4504089 100644
--- a/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
+++ b/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
@@ -29,6 +29,7 @@ import org.apache.zeppelin.interpreter.InterpreterOutputListener;
 import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.interpreter.InterpreterResultMessageOutput;
 import org.apache.zeppelin.interpreter.LazyOpenInterpreter;
+import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
 import org.apache.zeppelin.user.AuthenticationInfo;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -38,6 +39,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
 
 import static org.junit.Assert.assertEquals;
@@ -813,6 +815,12 @@ public class LivyInterpreterIT {
       assertEquals(1, result.message().size());
       assertEquals(InterpreterResult.Type.IMG, result.message().get(0).getType());
 
+      // test code completion
+      List<InterpreterCompletion> completionResult = sparkInterpreter
+          .completion("df.sho", 6, context);
+      assertEquals(1, completionResult.size());
+      assertEquals("show", completionResult.get(0).name);
+
     } finally {
       sparkInterpreter.close();
       sqlInterpreter.close();


Mime
View raw message