v.20.12New Feature

Add aggregate_functions_null_for_empty setting for SQL standard compatibility

Add setting aggregate_functions_null_for_empty for SQL standard compatibility. This option will rewrite all aggregate functions in a query, adding -OrNull suffix to them. Implements 10273. #16123 (flynn).
Introduces the aggregate_functions_null_for_empty setting that rewrites all aggregate functions in a query by adding an -OrNull suffix to ensure SQL standard compatibility.

Why it matters

This feature addresses the discrepancy between ClickHouse aggregate functions and the SQL standard by making aggregate functions return null for empty input sets, improving query consistency and compatibility with SQL expectations.

How to use it

Enable the feature by setting aggregate_functions_null_for_empty = 1 in the session or query settings. This will automatically rewrite aggregate functions to their -OrNull variants during query execution.