Skip to content

Commit 1a3d0cd

Browse files
committed
Revert "[SPARK-12105] [SQL] add convenient show functions"
This reverts commit 31b3910.
1 parent 18ea11c commit 1a3d0cd

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,17 @@ class DataFrame private[sql](
160160
}
161161
}
162162

163-
/**
164-
* Compose the string representing rows for output
165-
*/
166-
def showString(): String = {
167-
showString(20)
168-
}
169-
170163
/**
171164
* Compose the string representing rows for output
172-
* @param numRows Number of rows to show
165+
* @param _numRows Number of rows to show
173166
* @param truncate Whether truncate long strings and align cells right
174167
*/
175-
def showString(numRows: Int, truncate: Boolean = true): String = {
176-
val _numRows = numRows.max(0)
168+
private[sql] def showString(_numRows: Int, truncate: Boolean = true): String = {
169+
val numRows = _numRows.max(0)
177170
val sb = new StringBuilder
178-
val takeResult = take(_numRows + 1)
179-
val hasMoreData = takeResult.length > _numRows
180-
val data = takeResult.take(_numRows)
171+
val takeResult = take(numRows + 1)
172+
val hasMoreData = takeResult.length > numRows
173+
val data = takeResult.take(numRows)
181174
val numCols = schema.fieldNames.length
182175

183176
// For array values, replace Seq and Array with square brackets
@@ -231,10 +224,10 @@ class DataFrame private[sql](
231224

232225
sb.append(sep)
233226

234-
// For Data that has more than "_numRows" records
227+
// For Data that has more than "numRows" records
235228
if (hasMoreData) {
236-
val rowsString = if (_numRows == 1) "row" else "rows"
237-
sb.append(s"only showing top $_numRows $rowsString\n")
229+
val rowsString = if (numRows == 1) "row" else "rows"
230+
sb.append(s"only showing top $numRows $rowsString\n")
238231
}
239232

240233
sb.toString()

0 commit comments

Comments
 (0)