Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

aggregate_* session settings

These settings are available in system.settings and are autogenerated from source.

aggregate_function_input_format

Type
AggregateFunctionInputFormat
Default
state
Version history
VersionDefault valueComment
25.12stateNew setting to control AggregateFunction input format during INSERT operations. Setting Value set to state by default

Format for AggregateFunction input during INSERT operations.

Possible values:

  • state — Binary string with the serialized state (the default). This is the default behavior where AggregateFunction values are expected as binary data.
  • value — The format expects a single value of the argument of the aggregate function, or in the case of multiple arguments, a tuple of them. They will be deserialized using the corresponding IDataType or DataTypeTuple and then aggregated to form the state.
  • array — The format expects an Array of values, as described in the value option above. All elements of the array will be aggregated to form the state.

Examples

For a table with structure:

CREATE TABLE example (
    user_id UInt64,
    avg_session_length AggregateFunction(avg, UInt32)
);

With aggregate_function_input_format = 'value':

INSERT INTO example FORMAT CSV
123,456

With aggregate_function_input_format = 'array':

INSERT INTO example FORMAT CSV
123,"[456,789,101]"

Note: The value and array formats are slower than the default state format as they require creating and aggregating values during insertion.

aggregate_functions_null_for_empty

Type
Bool
Default
0

Enables or disables rewriting all aggregate functions in a query, adding -OrNull suffix to them. Enable it for SQL standard compatibility. It is implemented via query rewrite (similar to count_distinct_implementation setting) to get consistent results for distributed queries.

Possible values:

  • 0 — Disabled.
  • 1 — Enabled.

Example

Consider the following query with aggregate functions:

SELECT SUM(-1), MAX(0) FROM system.one WHERE 0;

With aggregate_functions_null_for_empty = 0 it would produce:

┌─SUM(-1)─┬─MAX(0)─┐
│       0 │      0 │
└─────────┴────────┘

With aggregate_functions_null_for_empty = 1 the result would be:

┌─SUMOrNull(-1)─┬─MAXOrNull(0)─┐
│          NULL │         NULL │
└───────────────┴──────────────┘
Navigation