frameless icon indicating copy to clipboard operation
frameless copied to clipboard

Aggregation with collectSet on empty dataset produces Null

Open ayoub-benali opened this issue 5 years ago • 0 comments

Consider the following example:

import frameless.functions.aggregate.{collectSet, max, min}
import frameless.syntax._
import frameless.TypedDataset

case class Foo(bar: Int)
val ds = TypedDataset.create(List.empty[Foo])

ds
  .agg(
    min(ds('bar)),
    collectSet(ds('bar))
  )
  .collect
  .run

It produces WrappedArray(null) while the expected value would be WrappedArray() because the initial dataset is empty. Please note that this bug happen only when collectSet is combined with an other aggregation. Aggregating only with min produces the expected result.

While using only collectSet

ds.agg(collectSet(ds('bar))).collect.run

Produces WrappedArray(Vector()) while the expected value is WrappedArray()

I haven't tested with the other collect functions llke collectList

ayoub-benali avatar Oct 23 '20 12:10 ayoub-benali