zjffdu 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_r255384380
##########
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:
fixed
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services