You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2016/11/07 04:24:42 UTC
zeppelin git commit: [ZEPPELIN-1451] Bug fix of Embedding %html
within %table.
Repository: zeppelin
Updated Branches:
refs/heads/master cb175032a -> 1cde24665
[ZEPPELIN-1451] Bug fix of Embedding %html within %table.
### What is this PR for?
This PR fixes the bug of Embedding %html within %table.
It doesn't print properly when the `%html` is the first line.
### What type of PR is it?
Bug Fix
### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1451
### How should this be tested?
Run following code in your paragraph.
```
print(s"""%table
name\tsize\tquantity
%html <img src='https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Sun_symbol.svg/50px-Sun_symbol.svg.png' />sun\t100\t50
%html <img src='https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Moon_symbol_crescent.svg/25px-Moon_symbol_crescent.svg.png' />moon\t10\t20""")
```
### Screenshots (if appropriate)
- before
![image](https://cloud.githubusercontent.com/assets/3348133/18616055/30262a38-7df0-11e6-8d9c-441f50df77c6.png)
- after
![image](https://cloud.githubusercontent.com/assets/3348133/18616073/73ba51c0-7df0-11e6-8a91-b13074ec80e4.png)
### Questions:
- Does the licenses files need update? no
- Is there breaking changes for older versions? no
- Does this needs documentation? no
Author: astroshim <hs...@nflabs.com>
Closes #1433 from astroshim/ZEPPELIN-1451 and squashes the following commits:
0db87e3 [astroshim] Merge branch 'master' into ZEPPELIN-1451
fcdd7e5 [astroshim] rebase
c4bda4d [astroshim] rebase
7d82a94 [astroshim] Merge branch 'ZEPPELIN-1451' of https://github.com/astroshim/zeppelin into ZEPPELIN-1451
265a82b [astroshim] change scope
51aa813 [astroshim] add PySparkInterpreter testcase.
3fe0c7e [astroshim] Merge branch 'master' into feat/pySparkInterpreterTest
499aa6b [astroshim] add PySparkInterpreter testcase
1d0ab93 [astroshim] add testcase
89a40b3 [astroshim] change condition of parsing
a7a88e6 [astroshim] Merge branch 'master' of https://github.com/apache/zeppelin into ZEPPELIN-1451
7724afd [astroshim] Merge branch 'master' into ZEPPELIN-1451
f3d11a0 [astroshim] add checking the type should be detected.
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/1cde2466
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/1cde2466
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/1cde2466
Branch: refs/heads/master
Commit: 1cde24665180e8f10651012f53d7bcb58ea2eb44
Parents: cb17503
Author: astroshim <hs...@nflabs.com>
Authored: Sat Nov 5 21:12:20 2016 +0900
Committer: Lee moon soo <mo...@apache.org>
Committed: Sun Nov 6 20:24:26 2016 -0800
----------------------------------------------------------------------
.../org/apache/zeppelin/interpreter/InterpreterOutput.java | 8 +++++++-
.../apache/zeppelin/interpreter/InterpreterOutputTest.java | 7 +++++++
2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1cde2466/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutput.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutput.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutput.java
index 6d21d22..5a2e0ca 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutput.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutput.java
@@ -213,11 +213,17 @@ public class InterpreterOutput extends OutputStream {
return out.toByteArray();
}
+ private boolean typeShouldBeDetected() {
+ return getType() == InterpreterResult.Type.TABLE ? false : true;
+ }
+
public void flush() throws IOException {
synchronized (outList) {
buffer.flush();
byte[] bytes = buffer.toByteArray();
- bytes = detectTypeFromLine(bytes);
+ if (typeShouldBeDetected()) {
+ bytes = detectTypeFromLine(bytes);
+ }
if (bytes != null) {
outList.add(bytes);
if (type == InterpreterResult.Type.TEXT) {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1cde2466/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java
index f8f4809..28a2a86 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java
@@ -115,6 +115,13 @@ public class InterpreterOutputTest implements InterpreterOutputListener {
assertEquals(InterpreterResult.Type.HTML, out.getType());
}
+ @Test
+ public void testMagicData() throws IOException {
+ out.write("%table col1\tcol2\n%html <h3> This is a hack </h3>\t234\n".getBytes());
+ assertEquals(InterpreterResult.Type.TABLE, out.getType());
+ assertEquals("col1\tcol2\n%html <h3> This is a hack </h3>\t234\n", new String(out.toByteArray()));
+ }
+
@Override
public void onAppend(InterpreterOutput out, byte[] line) {
numAppendEvent++;