You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by an...@apache.org on 2015/12/16 03:08:29 UTC
spark git commit: [SPARK-12105] [SQL] add convenient show functions
Repository: spark
Updated Branches:
refs/heads/master 28112657e -> 31b391019
[SPARK-12105] [SQL] add convenient show functions
Author: Jean-Baptiste Onofré <jb...@apache.org>
Closes #10130 from jbonofre/SPARK-12105.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/31b39101
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/31b39101
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/31b39101
Branch: refs/heads/master
Commit: 31b391019ff6eb5a483f4b3e62fd082de7ff8416
Parents: 2811265
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Tue Dec 15 18:06:30 2015 -0800
Committer: Andrew Or <an...@databricks.com>
Committed: Tue Dec 15 18:08:09 2015 -0800
----------------------------------------------------------------------
.../scala/org/apache/spark/sql/DataFrame.scala | 25 +++++++++++++-------
1 file changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/31b39101/sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala b/sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala
index 497bd48..b69d441 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala
@@ -161,16 +161,23 @@ class DataFrame private[sql](
}
/**
+ * Compose the string representing rows for output
+ */
+ def showString(): String = {
+ showString(20)
+ }
+
+ /**
* Compose the string representing rows for output
- * @param _numRows Number of rows to show
+ * @param numRows Number of rows to show
* @param truncate Whether truncate long strings and align cells right
*/
- private[sql] def showString(_numRows: Int, truncate: Boolean = true): String = {
- val numRows = _numRows.max(0)
+ def showString(numRows: Int, truncate: Boolean = true): String = {
+ val _numRows = numRows.max(0)
val sb = new StringBuilder
- val takeResult = take(numRows + 1)
- val hasMoreData = takeResult.length > numRows
- val data = takeResult.take(numRows)
+ val takeResult = take(_numRows + 1)
+ val hasMoreData = takeResult.length > _numRows
+ val data = takeResult.take(_numRows)
val numCols = schema.fieldNames.length
// For array values, replace Seq and Array with square brackets
@@ -224,10 +231,10 @@ class DataFrame private[sql](
sb.append(sep)
- // For Data that has more than "numRows" records
+ // For Data that has more than "_numRows" records
if (hasMoreData) {
- val rowsString = if (numRows == 1) "row" else "rows"
- sb.append(s"only showing top $numRows $rowsString\n")
+ val rowsString = if (_numRows == 1) "row" else "rows"
+ sb.append(s"only showing top $_numRows $rowsString\n")
}
sb.toString()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org