typelevel / typelevel/frameless
Aggregation with collectSet on empty dataset produces Null
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 895
- Forks
- 135
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 3
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the empty TypedDataset example with collectSet combined with min, then inspect the collectSet aggregation implementation and related tests. Done means empty input returns WrappedArray() both alone and when combined with another aggregation, without changing the behavior of non-empty inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala, spark
- Domain
- data-engineering
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100