Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/19401#discussion_r142002605
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -238,8 +238,9 @@ class Dataset[T] private[sql](
private[sql] def showString(
_numRows: Int, truncate: Int = 20, vertical: Boolean = false):
String = {
val numRows = _numRows.max(0)
- val takeResult = toDF().take(numRows + 1)
- val hasMoreData = takeResult.length > numRows
+ val numTotalRows = toDF().count()
--- End diff --
You don't want to do a whole count() here -- could be quite expensive.
Instead just something like:
```
val takeResult = toDF().take(if (numRows == Int.MaxValue) numRows else
numRows + 1)
val hasMoreData = takeResult.length > numRows
val data = takeResult.take(numRows)
```
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]