Skip to content

Commit

Permalink
Update useful-setting-to-turn-on.md
Browse files Browse the repository at this point in the history
  • Loading branch information
den-crane committed Mar 30, 2022
1 parent 5ca6a80 commit 9daa250
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,21 @@ Possible values:

0 — The empty cells are filled with the default value of the corresponding field type.
1 — JOIN behaves the same way as in standard SQL. The type of the corresponding field is converted to Nullable, and empty cells are filled with NULL.

* [aggregate_functions_null_for_empty](https://clickhouse.com/docs/en/operations/settings/settings/#aggregate_functions_null_for_empty)

Default behaviour is not compatible with ANSI SQL (ClickHouse avoids Nullable types by perfomance reasons)

```sql
select sum(x), avg(x) from (select 1 x where 0);
┌─sum(x)─┬─avg(x)─┐
0 │ nan │
└────────┴────────┘

set aggregate_functions_null_for_empty=1;

select sum(x), avg(x) from (select 1 x where 0);
┌─sumOrNull(x)─┬─avgOrNull(x)─┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │
└──────────────┴──────────────┘
```

0 comments on commit 9daa250

Please sign in to comment.