Skip to content

Commit

Permalink
SQL: Fix SUM(all zeroes) to return 0 instead of NULL (#65796)
Browse files Browse the repository at this point in the history
Previously the SUM(all zeroes) was `NULL`, but after this change the SUM
SQL function call is automatically upgraded into a `stats` aggregation
instead of a `sum` aggregation. The `stats` aggregation only results in
`NULL` if the there were no rows, no values (all nulls) to aggregate, which 
is the expected behaviour across different SQL implementations.

This is a workaround for the issue #45251 . Once the results of the `sum` 
aggregation can differentiate between `SUM(all nulls)` and 
`SUM(all zeroes`) the optimizer rule introduced in this commit needs to be
removed.
  • Loading branch information
Andras Palinkas authored Dec 9, 2020
1 parent 8796c3e commit b74792a
Show file tree
Hide file tree
Showing 6 changed files with 550 additions and 32 deletions.
Loading

0 comments on commit b74792a

Please sign in to comment.