confluentinc / confluentinc/ksql

avg should return null when no row is aggregated

Open
#9,752 1 comment 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Java
Stars
315
Forks
1k
Avg merge
1d 7h
Merged PRs (30d)
36

Description

**Is your feature request related to a problem? Please describe.**
[avg](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/aggregate-functions/#avg) returns `0.0` instead of `NULL` when no row is aggregated. However, IMHO, `NULL` is preferable because `0.0` means nothing. In addition, other projects like apache spark return null in this case. What do you think?

**Describe the solution you'd like**
[avg](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/aggregate-functions/#avg) should return null when no row is aggregated.

**Describe alternatives you've considered**

**Additional context**

Contributor guide

Open the contributing guide

Research direction

Start with the avg aggregate-function documentation linked in the issue and trace the corresponding implementation and tests in the ksql repository. Confirm the behavior when no rows are aggregated, then update the relevant coverage so the result is NULL rather than 0.0 and verify the aggregate-function tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases, stream-processing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.