Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Aggregation with collectSet on empty dataset produces Null

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

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
scala, spark

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.

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

Dominant language
Scala
Stars
895
Forks
135
Avg merge
7h 38m
Merged PRs (30d)
1

Getting set up

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.

More from typelevel/frameless

All issues in typelevel/frameless

Similar issues

More Scala issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.