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: - https://github.com/substrait-io/substrait/pull/953#discussion_r2866240566 - https://github.com/substrait-io/substrait/pull/953#discussion_r2866233519
Currently,
sumof zero elements returns NULL, matching the SQL standard and mostdatabases (PostgreSQL, DuckDB, Spark, Trino, SQLite).
However, some engines like ClickHouse return 0 for sum of an empty set:
We should consider adding an option to make this behavior configurable.
Context: