Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQL: Fix SUM(all zeroes) to return 0 instead of NULL (elastic#65796)
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 elastic#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. (cherry-picked from b74792a)
- Loading branch information