Skip to content

Make sum-of-empty-set behavior configurable (NULL vs 0) #997

@kadinrabo

Description

@kadinrabo

Currently, sum of zero elements returns NULL, matching the SQL standard and most
databases (PostgreSQL, DuckDB, Spark, Trino, SQLite).

However, some engines like ClickHouse return 0 for sum of an empty set:

docker run clickhouse/clickhouse-server:latest clickhouse-local \
  --query "SELECT SUM(x) FROM (SELECT 1 AS x WHERE false) t"

We should consider adding an option to make this behavior configurable.

Context:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions