Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21291#discussion_r187565401
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
    @@ -2767,7 +2767,12 @@ class Dataset[T] private[sql](
        * @since 1.6.0
        */
       def count(): Long = withAction("count", 
groupBy().count().queryExecution) { plan =>
    -    plan.executeCollect().head.getLong(0)
    +    val collected = plan.executeCollect()
    +    if (collected.isEmpty) {
    +      0
    +    } else {
    +      collected.head.getLong(0)
    +    }
    --- End diff --
    
    I think it is caused by returning `SinglePartition` when there is no data 
(and therefore no partition). So I think we should fix it there and not here.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to