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 2021/07/12 04:17:01 UTC

[GitHub] [zeppelin] zjffdu commented on a change in pull request #4169: [ZEPPELIN-5454] Explain output should be in text format

zjffdu commented on a change in pull request #4169:
URL: https://github.com/apache/zeppelin/pull/4169#discussion_r667613020



##########
File path: spark/spark1-shims/src/main/scala/org/apache/zeppelin/spark/Spark1Shims.java
##########
@@ -81,17 +82,28 @@ public String showDataFrame(Object obj, int maxResult, InterpreterContext contex
         }
       }
 
+      InterpreterResult.Type outputType = InterpreterResult.Type.TABLE;
+      String sql = context.getLocalProperties().get("sql");
+      if (StringUtils.isNotBlank(sql) && sql.trim().toLowerCase().startsWith("explain")) {
+        outputType = InterpreterResult.Type.TEXT;
+      }
+
       StringBuilder msg = new StringBuilder();
-      msg.append("\n%table ");
+      msg.append("\n%" + outputType.toString().toLowerCase() + " ");

Review comment:
       I think JVM will optimize it via StringBuilder, I write in this way just for readability purpose. 
   https://stackoverflow.com/questions/1532461/stringbuilder-vs-string-concatenation-in-tostring-in-java




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org