You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by GitBox <gi...@apache.org> on 2019/12/28 13:58:23 UTC

[GitHub] [zeppelin] zjffdu commented on a change in pull request #3579: [ZEPPELIN-4522]. Support multiple sql statements for SparkSqlInterpreter

zjffdu commented on a change in pull request #3579: [ZEPPELIN-4522]. Support multiple sql statements for SparkSqlInterpreter
URL: https://github.com/apache/zeppelin/pull/3579#discussion_r361796422
 
 

 ##########
 File path: spark/interpreter/src/main/java/org/apache/zeppelin/spark/SparkSqlInterpreter.java
 ##########
 @@ -82,26 +85,35 @@ public InterpreterResult internalInterpret(String st, InterpreterContext context
     sparkInterpreter.getZeppelinContext().setInterpreterContext(context);
     SQLContext sqlc = sparkInterpreter.getSQLContext();
     SparkContext sc = sqlc.sparkContext();
-    sc.setLocalProperty("spark.scheduler.pool", context.getLocalProperties().get("pool"));
-    sc.setJobGroup(Utils.buildJobGroupId(context), Utils.buildJobDesc(context), false);
-
-    try {
-      Method method = sqlc.getClass().getMethod("sql", String.class);
-      int maxResult = Integer.parseInt(context.getLocalProperties().getOrDefault("limit",
-              "" + sparkInterpreter.getZeppelinContext().getMaxResult()));
-      String msg = sparkInterpreter.getZeppelinContext().showData(
-          method.invoke(sqlc, st), maxResult);
-      sc.clearJobGroup();
-      return new InterpreterResult(Code.SUCCESS, msg);
-    } catch (Exception e) {
-      if (Boolean.parseBoolean(getProperty("zeppelin.spark.sql.stacktrace"))) {
-        return new InterpreterResult(Code.ERROR, ExceptionUtils.getStackTrace(e));
+
+    StringBuilder builder = new StringBuilder();
+    List<String> sqls = sqlSplitter.splitSql(st);
+    for (String sql : sqls) {
+      sc.setLocalProperty("spark.scheduler.pool", context.getLocalProperties().get("pool"));
+      sc.setJobGroup(Utils.buildJobGroupId(context), Utils.buildJobDesc(context), false);
 
 Review comment:
   Make sense 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services