Skip to content
Snippets Groups Projects
Commit 1a3d0cd9 authored by Reynold Xin's avatar Reynold Xin
Browse files

Revert "[SPARK-12105] [SQL] add convenient show functions"

This reverts commit 31b39101.
parent 18ea11c3
No related branches found
No related tags found
No related merge requests found
...@@ -160,24 +160,17 @@ class DataFrame private[sql]( ...@@ -160,24 +160,17 @@ class DataFrame private[sql](
} }
} }
/**
* Compose the string representing rows for output
*/
def showString(): String = {
showString(20)
}
/** /**
* Compose the string representing rows for output * 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 * @param truncate Whether truncate long strings and align cells right
*/ */
def showString(numRows: Int, truncate: Boolean = true): String = { private[sql] def showString(_numRows: Int, truncate: Boolean = true): String = {
val _numRows = numRows.max(0) val numRows = _numRows.max(0)
val sb = new StringBuilder val sb = new StringBuilder
val takeResult = take(_numRows + 1) val takeResult = take(numRows + 1)
val hasMoreData = takeResult.length > _numRows val hasMoreData = takeResult.length > numRows
val data = takeResult.take(_numRows) val data = takeResult.take(numRows)
val numCols = schema.fieldNames.length val numCols = schema.fieldNames.length
// For array values, replace Seq and Array with square brackets // For array values, replace Seq and Array with square brackets
...@@ -231,10 +224,10 @@ class DataFrame private[sql]( ...@@ -231,10 +224,10 @@ class DataFrame private[sql](
sb.append(sep) sb.append(sep)
// For Data that has more than "_numRows" records // For Data that has more than "numRows" records
if (hasMoreData) { if (hasMoreData) {
val rowsString = if (_numRows == 1) "row" else "rows" val rowsString = if (numRows == 1) "row" else "rows"
sb.append(s"only showing top $_numRows $rowsString\n") sb.append(s"only showing top $numRows $rowsString\n")
} }
sb.toString() sb.toString()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment