Skip to content

Commit aea8446

Browse files
Merge branch 'apache/master'
2 parents df1620c + cc24227 commit aea8446

File tree

10 files changed

+163
-51
lines changed

10 files changed

+163
-51
lines changed

bin/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ if [[ -z "${ZEPPELIN_INTP_MEM}" ]]; then
104104
export ZEPPELIN_INTP_MEM="${ZEPPELIN_MEM}"
105105
fi
106106

107-
JAVA_INTP_OPTS+=" ${ZEPPELIN_INTP_JAVA_OPTS} -Dfile.encoding=${ZEPPELIN_ENCODING}"
107+
JAVA_INTP_OPTS="${ZEPPELIN_INTP_JAVA_OPTS} -Dfile.encoding=${ZEPPELIN_ENCODING}"
108108
export JAVA_INTP_OPTS
109109

110110

spark/src/main/java/org/apache/zeppelin/spark/SparkInterpreter.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -481,18 +481,18 @@ public void open() {
481481

482482
System.setProperty("scala.repl.name.line", "line" + this.hashCode() + "$");
483483

484-
/* create scala repl */
485-
this.interpreter = new SparkILoop(null, new PrintWriter(out));
484+
synchronized (sharedInterpreterLock) {
485+
/* create scala repl */
486+
this.interpreter = new SparkILoop(null, new PrintWriter(out));
486487

487-
interpreter.settings_$eq(settings);
488+
interpreter.settings_$eq(settings);
488489

489-
interpreter.createInterpreter();
490+
interpreter.createInterpreter();
490491

491-
intp = interpreter.intp();
492-
intp.setContextClassLoader();
493-
intp.initializeSynchronous();
492+
intp = interpreter.intp();
493+
intp.setContextClassLoader();
494+
intp.initializeSynchronous();
494495

495-
synchronized (sharedInterpreterLock) {
496496
if (classOutputDir == null) {
497497
classOutputDir = settings.outputDirs().getSingleOutput().get();
498498
} else {
@@ -523,35 +523,35 @@ public void open() {
523523
sparkVersion = SparkVersion.fromVersionString(sc.version());
524524

525525
sqlc = getSQLContext();
526-
}
527-
528-
dep = getDependencyResolver();
529-
530-
z = new ZeppelinContext(sc, sqlc, null, dep,
531-
Integer.parseInt(getProperty("zeppelin.spark.maxResult")));
532526

533-
intp.interpret("@transient var _binder = new java.util.HashMap[String, Object]()");
534-
binder = (Map<String, Object>) getValue("_binder");
535-
binder.put("sc", sc);
536-
binder.put("sqlc", sqlc);
537-
binder.put("z", z);
538-
539-
intp.interpret("@transient val z = "
540-
+ "_binder.get(\"z\").asInstanceOf[org.apache.zeppelin.spark.ZeppelinContext]");
541-
intp.interpret("@transient val sc = "
542-
+ "_binder.get(\"sc\").asInstanceOf[org.apache.spark.SparkContext]");
543-
intp.interpret("@transient val sqlc = "
544-
+ "_binder.get(\"sqlc\").asInstanceOf[org.apache.spark.sql.SQLContext]");
545-
intp.interpret("@transient val sqlContext = "
546-
+ "_binder.get(\"sqlc\").asInstanceOf[org.apache.spark.sql.SQLContext]");
547-
intp.interpret("import org.apache.spark.SparkContext._");
548-
549-
if (sparkVersion.oldSqlContextImplicits()) {
550-
intp.interpret("import sqlContext._");
551-
} else {
552-
intp.interpret("import sqlContext.implicits._");
553-
intp.interpret("import sqlContext.sql");
554-
intp.interpret("import org.apache.spark.sql.functions._");
527+
dep = getDependencyResolver();
528+
529+
z = new ZeppelinContext(sc, sqlc, null, dep,
530+
Integer.parseInt(getProperty("zeppelin.spark.maxResult")));
531+
532+
intp.interpret("@transient var _binder = new java.util.HashMap[String, Object]()");
533+
binder = (Map<String, Object>) getValue("_binder");
534+
binder.put("sc", sc);
535+
binder.put("sqlc", sqlc);
536+
binder.put("z", z);
537+
538+
intp.interpret("@transient val z = "
539+
+ "_binder.get(\"z\").asInstanceOf[org.apache.zeppelin.spark.ZeppelinContext]");
540+
intp.interpret("@transient val sc = "
541+
+ "_binder.get(\"sc\").asInstanceOf[org.apache.spark.SparkContext]");
542+
intp.interpret("@transient val sqlc = "
543+
+ "_binder.get(\"sqlc\").asInstanceOf[org.apache.spark.sql.SQLContext]");
544+
intp.interpret("@transient val sqlContext = "
545+
+ "_binder.get(\"sqlc\").asInstanceOf[org.apache.spark.sql.SQLContext]");
546+
intp.interpret("import org.apache.spark.SparkContext._");
547+
548+
if (sparkVersion.oldSqlContextImplicits()) {
549+
intp.interpret("import sqlContext._");
550+
} else {
551+
intp.interpret("import sqlContext.implicits._");
552+
intp.interpret("import sqlContext.sql");
553+
intp.interpret("import org.apache.spark.sql.functions._");
554+
}
555555
}
556556

557557
/* Temporary disabling DisplayUtils. see https://issues.apache.org/jira/browse/ZEPPELIN-127

spark/src/main/java/org/apache/zeppelin/spark/SparkSqlInterpreter.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public class SparkSqlInterpreter extends Interpreter {
6060
SparkInterpreter.getSystemDefault("ZEPPELIN_SPARK_CONCURRENTSQL",
6161
"zeppelin.spark.concurrentSQL", "false"),
6262
"Execute multiple SQL concurrently if set true.")
63+
.add("zeppelin.spark.sql.stacktrace",
64+
SparkInterpreter.getSystemDefault("ZEPPELIN_SPARK_SQL_STACKTRACE",
65+
"zeppelin.spark.sql.stacktrace", "false"),
66+
"Show full exception stacktrace for SQL queries if set to true.")
6367
.build());
6468
}
6569

@@ -131,8 +135,16 @@ public InterpreterResult interpret(String st, InterpreterContext context) {
131135
// Therefore need to use reflection to keep binary compatibility for all spark versions.
132136
Method sqlMethod = sqlc.getClass().getMethod("sql", String.class);
133137
rdd = sqlMethod.invoke(sqlc, st);
138+
} catch (InvocationTargetException ite) {
139+
if (Boolean.parseBoolean(getProperty("zeppelin.spark.sql.stacktrace"))) {
140+
throw new InterpreterException(ite);
141+
}
142+
logger.error("Invocation target exception", ite);
143+
String msg = ite.getTargetException().getMessage()
144+
+ "\nset zeppelin.spark.sql.stacktrace = true to see full stacktrace";
145+
return new InterpreterResult(Code.ERROR, msg);
134146
} catch (NoSuchMethodException | SecurityException | IllegalAccessException
135-
| IllegalArgumentException | InvocationTargetException e) {
147+
| IllegalArgumentException e) {
136148
throw new InterpreterException(e);
137149
}
138150

spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,10 @@ public void test() {
110110
assertEquals(Type.TABLE, ret.type());
111111
assertEquals("name\tage\nmoon\t33\npark\t34\n", ret.message());
112112

113-
try {
114-
sql.interpret("select wrong syntax", context);
115-
fail("Exception not catched");
116-
} catch (Exception e) {
117-
// okay
118-
LOGGER.info("Exception in SparkSqlInterpreterTest while test ", e);
119-
}
113+
ret = sql.interpret("select wrong syntax", context);
114+
assertEquals(InterpreterResult.Code.ERROR, ret.code());
115+
assertTrue(ret.message().length() > 0);
116+
120117
assertEquals(InterpreterResult.Code.SUCCESS, sql.interpret("select case when name==\"aa\" then name else name end from test", context).code());
121118
}
122119

zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public synchronized void init() {
131131
interpreterProcess.reference(getInterpreterGroup());
132132
interpreterProcess.setMaxPoolSize(
133133
Math.max(this.maxPoolSize, interpreterProcess.getMaxPoolSize()));
134+
String groupId = getInterpreterGroup().getId();
134135

135136
synchronized (interpreterProcess) {
136137
Client client = null;
@@ -144,7 +145,7 @@ public synchronized void init() {
144145
try {
145146
logger.info("Create remote interpreter {}", getClassName());
146147
property.put("zeppelin.interpreter.localRepo", localRepoPath);
147-
client.createInterpreter(getInterpreterGroup().getId(), noteId,
148+
client.createInterpreter(groupId, noteId,
148149
getClassName(), (Map) property);
149150
} catch (TException e) {
150151
broken = true;

zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,109 @@ public void testWidth() throws Exception {
322322
CoreMatchers.equalTo(true));
323323
}
324324
} catch (Exception e) {
325-
handleException("Exception in ParagraphActionsIT while testWidth ", e);
325+
handleException("Exception in ParagraphActionsIT while testWidth ", e);
326326
}
327327

328328
}
329329

330+
@Test
331+
public void testTitleButton() throws Exception {
332+
if (!endToEndTestEnabled()) {
333+
return;
334+
}
335+
try {
336+
createNewNote();
337+
338+
waitForParagraph(1, "READY");
339+
340+
String xpathToTitle = getParagraphXPath(1) + "//div[contains(@class, 'title')]/div";
341+
String xpathToSettingIcon = getParagraphXPath(1) + "//span[@class='icon-settings']";
342+
String xpathToShowTitle=getParagraphXPath(1) + "//ul/li/a[@ng-click='showTitle()']";
343+
String xpathToHideTitle=getParagraphXPath(1) + "//ul/li/a[@ng-click='hideTitle()']";
344+
345+
collector.checkThat("Before Show Title : The title field contains",
346+
driver.findElement(By.xpath(xpathToTitle)).getText(),
347+
CoreMatchers.equalTo(""));
348+
driver.findElement(By.xpath(xpathToSettingIcon)).click();
349+
collector.checkThat("Before Show Title : The title option in option panel of paragraph is labeled as ",
350+
driver.findElement(By.xpath(xpathToShowTitle)).getText(),
351+
CoreMatchers.equalTo("Show title"));
352+
353+
driver.findElement(By.xpath(xpathToShowTitle)).click();
354+
collector.checkThat("After Show Title : The title field contains",
355+
driver.findElement(By.xpath(xpathToTitle)).getText(),
356+
CoreMatchers.equalTo("Untitled"));
357+
358+
driver.findElement(By.xpath(xpathToSettingIcon)).click();
359+
collector.checkThat("After Show Title : The title option in option panel of paragraph is labeled as",
360+
driver.findElement(By.xpath(xpathToHideTitle)).getText(),
361+
CoreMatchers.equalTo("Hide title"));
362+
363+
driver.findElement(By.xpath(xpathToHideTitle)).click();
364+
collector.checkThat("After Hide Title : The title field contains",
365+
driver.findElement(By.xpath(xpathToTitle)).getText(),
366+
CoreMatchers.equalTo(""));
367+
driver.findElement(By.xpath(xpathToSettingIcon)).click();
368+
driver.findElement(By.xpath(xpathToShowTitle)).click();
369+
370+
driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'title')]")).click();
371+
driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).sendKeys("NEW TITLE" + Keys.ENTER);
372+
collector.checkThat("After Editing the Title : The title field contains ",
373+
driver.findElement(By.xpath(xpathToTitle)).getText(),
374+
CoreMatchers.equalTo("NEW TITLE"));
375+
driver.navigate().refresh();
376+
ZeppelinITUtils.sleep(1000, false);
377+
collector.checkThat("After Page Refresh : The title field contains ",
378+
driver.findElement(By.xpath(xpathToTitle)).getText(),
379+
CoreMatchers.equalTo("NEW TITLE"));
380+
ZeppelinITUtils.sleep(1000, false);
381+
deleteTestNotebook(driver);
382+
383+
} catch (Exception e) {
384+
handleException("Exception in ParagraphActionsIT while testTitleButton ", e);
385+
}
386+
387+
}
388+
389+
@Test
390+
public void testShowAndHideLineNumbers() throws Exception {
391+
if (!endToEndTestEnabled()) {
392+
return;
393+
}
394+
try {
395+
createNewNote();
396+
397+
waitForParagraph(1, "READY");
398+
String xpathToLineNumberField=getParagraphXPath(1) + "//div[contains(@class, 'ace_gutter-layer')]";
399+
String xpathToShowLineNumberButton=getParagraphXPath(1) + "//ul/li/a[@ng-click='showLineNumbers()']";
400+
String xpathToHideLineNumberButton=getParagraphXPath(1) + "//ul/li/a[@ng-click='hideLineNumbers()']";
401+
402+
collector.checkThat("Before \"Show line number\" the Line Number is Enabled ",
403+
driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(),
404+
CoreMatchers.equalTo(false));
405+
driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click();
406+
collector.checkThat("Before \"Show line number\" The option panel in paragraph has button labeled ",
407+
driver.findElement(By.xpath(xpathToShowLineNumberButton)).getText(),
408+
CoreMatchers.equalTo("Show line numbers"));
409+
driver.findElement(By.xpath(xpathToShowLineNumberButton)).click();
410+
collector.checkThat("After \"Show line number\" the Line Number is Enabled ",
411+
driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(),
412+
CoreMatchers.equalTo(true));
413+
driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click();
414+
collector.checkThat("After \"Show line number\" The option panel in paragraph has button labeled ",
415+
driver.findElement(By.xpath(xpathToHideLineNumberButton)).getText(),
416+
CoreMatchers.equalTo("Hide line numbers"));
417+
driver.findElement(By.xpath(xpathToHideLineNumberButton)).click();
418+
collector.checkThat("After \"Hide line number\" the Line Number is Enabled",
419+
driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(),
420+
CoreMatchers.equalTo(false));
421+
ZeppelinITUtils.sleep(1000, false);
422+
deleteTestNotebook(driver);
423+
424+
} catch (Exception e) {
425+
handleException("Exception in ParagraphActionsIT while testShowAndHideLineNumbers ", e);
426+
}
427+
}
428+
429+
330430
}

zeppelin-web/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@
163163
<groupId>org.apache.maven.plugins</groupId>
164164
<artifactId>maven-deploy-plugin</artifactId>
165165
<version>2.7</version>
166-
<configuration>
167-
<skip>true</skip>
168-
</configuration>
169166
</plugin>
170167

171168
<plugin>

zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ public void setPropertyAndRestart(String id,
664664
intpsetting.getInterpreterGroup().destroy();
665665

666666
intpsetting.setOption(option);
667+
intpsetting.setProperties(properties);
667668
intpsetting.setDependencies(dependencies);
668669

669670
InterpreterGroup interpreterGroup = createInterpreterGroup(intpsetting.id(), option);

zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public Properties getProperties() {
129129
return properties;
130130
}
131131

132+
public void setProperties(Properties properties) {
133+
this.properties = properties;
134+
}
135+
132136
public List<Dependency> getDependencies() {
133137
if (dependencies == null) {
134138
return new LinkedList<Dependency>();

zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private void updateParagraphResult(InterpreterOutput out) {
339339
}
340340

341341
static class ParagraphRunner extends InterpreterContextRunner {
342-
private Note note;
342+
private transient Note note;
343343

344344
public ParagraphRunner(Note note, String noteId, String paragraphId) {
345345
super(noteId, paragraphId);

0 commit comments

Comments
 (0)