Repository: zeppelin
Updated Branches:
  refs/heads/master 861f1d88f -> 5fd4ffc56


ZEPPELIN-2407. Livy Interpreter always return plain text result

### What is this PR for?
It happens when zeppelin.livy.displayAppInfo is true. Straightforward fix.

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

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-2407

### How should this be tested?
Test is added

### 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 #2254 from zjffdu/ZEPPELIN-2407 and squashes the following commits:

ba59a77 [Jeff Zhang] ZEPPELIN-2407. Livy Interpreter always return plain text 
result


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

Branch: refs/heads/master
Commit: 5fd4ffc56658884b8f671ca40b1f78b8354f1f69
Parents: 861f1d8
Author: Jeff Zhang <zjf...@apache.org>
Authored: Sun Apr 16 16:38:36 2017 +0800
Committer: Jeff Zhang <zjf...@apache.org>
Committed: Mon Apr 17 09:18:38 2017 +0800

----------------------------------------------------------------------
 .../apache/zeppelin/livy/BaseLivyInterprereter.java |  2 +-
 .../org/apache/zeppelin/livy/LivyInterpreterIT.java | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5fd4ffc5/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java
----------------------------------------------------------------------
diff --git 
a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java 
b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java
index 43cd507..77c98d9 100644
--- a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java
+++ b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java
@@ -379,7 +379,7 @@ public abstract class BaseLivyInterprereter extends 
Interpreter {
 
       if (displayAppInfo) {
         InterpreterResult interpreterResult = new 
InterpreterResult(InterpreterResult.Code.SUCCESS);
-        interpreterResult.add(InterpreterResult.Type.TEXT, result);
+        interpreterResult.add(result);
         String appInfoHtml = "<hr/>Spark Application Id: " + sessionInfo.appId 
+ "<br/>"
             + "Spark WebUI: <a href=\"" + sessionInfo.webUIAddress + "\">"
             + sessionInfo.webUIAddress + "</a>";

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5fd4ffc5/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 6537125..06da238 100644
--- a/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
+++ b/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
@@ -145,6 +145,13 @@ public class LivyInterpreterIT {
         assertTrue(result.message().get(0).getData().contains("defined object 
Person"));
       }
 
+      // html output
+      String htmlCode = "println(\"%html <h1> hello </h1>\")";
+      result = sparkInterpreter.interpret(htmlCode, context);
+      assertEquals(InterpreterResult.Code.SUCCESS, result.code());
+      assertEquals(1, result.message().size());
+      assertEquals(InterpreterResult.Type.HTML, 
result.message().get(0).getType());
+
       // error
       result = sparkInterpreter.interpret("println(a)", context);
       assertEquals(InterpreterResult.Code.ERROR, result.code());
@@ -626,8 +633,15 @@ public class LivyInterpreterIT {
       InterpreterResult result = sparkInterpreter.interpret("sc.version", 
context);
       assertEquals(InterpreterResult.Code.SUCCESS, result.code());
       assertEquals(2, result.message().size());
-
       assertTrue(result.message().get(1).getData().contains("Spark Application 
Id"));
+
+      // html output
+      String htmlCode = "println(\"%html <h1> hello </h1>\")";
+      result = sparkInterpreter.interpret(htmlCode, context);
+      assertEquals(InterpreterResult.Code.SUCCESS, result.code());
+      assertEquals(2, result.message().size());
+      assertEquals(InterpreterResult.Type.HTML, 
result.message().get(0).getType());
+
     } finally {
       sparkInterpreter.close();
     }

Reply via email to