typelevel / typelevel/frameless

Aggregation with collectSet on empty dataset produces Null

Open
#452 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.