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/02/03 07:39:07 UTC

[GitHub] felixcheung commented on a change in pull request #3301: ZEPPELIN-3975. Add limit local property for SparkInterpreter and JdbcInterpreter

felixcheung commented on a change in pull request #3301: ZEPPELIN-3975. Add limit local property for SparkInterpreter and JdbcInterpreter
URL: https://github.com/apache/zeppelin/pull/3301#discussion_r253290730
 
 

 ##########
 File path: spark/spark1-shims/src/main/scala/org/apache/zeppelin/spark/Spark1Shims.java
 ##########
 @@ -56,23 +56,27 @@ public String showDataFrame(Object obj, int maxResult) {
     if (obj instanceof DataFrame) {
       DataFrame df = (DataFrame) obj;
       String[] columns = df.columns();
+      // fetch maxResult+1 rows so that we can check whether it is larger than zeppelin.spark.maxResult
       List<Row> rows = df.takeAsList(maxResult + 1);
-
       StringBuilder msg = new StringBuilder();
       msg.append("%table ");
       msg.append(StringUtils.join(columns, "\t"));
       msg.append("\n");
+      boolean isLargerThanMaxResult = rows.size() > maxResult;
+      if (isLargerThanMaxResult) {
+        rows = rows.subList(0, maxResult);
+      }
       for (Row row : rows) {
         for (int i = 0; i < row.size(); ++i) {
           msg.append(row.get(i));
-          if (i != row.size() - 1) {
+          if (i != row.size() -1) {
 
 Review comment:
   space after `-` and before `1`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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