> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# aggregate_* session settings

> ClickHouse session settings in the aggregate_* generated group.

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>Type</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>Default</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          Changeable without restart
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

These settings are available in [system.settings](/docs/reference/system-tables/settings) and are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

<h2 id="aggregate_function_input_format">
  aggregate\_function\_input\_format
</h2>

<SettingsInfoBlock type="AggregateFunctionInputFormat" default_value="state" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.12"},{"label": "state"},{"label": "New 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:

```sql theme={null}
CREATE TABLE example (
    user_id UInt64,
    avg_session_length AggregateFunction(avg, UInt32)
);
```

With `aggregate_function_input_format = 'value'`:

```sql theme={null}
INSERT INTO example FORMAT CSV
123,456
```

With `aggregate_function_input_format = 'array'`:

```sql theme={null}
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.

<h2 id="aggregate_functions_null_for_empty">
  aggregate\_functions\_null\_for\_empty
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

Enables or disables rewriting all aggregate functions in a query, adding [-OrNull](/docs/reference/functions/aggregate-functions/combinators#-ornull) suffix to them. Enable it for SQL standard compatibility.
It is implemented via query rewrite (similar to [count\_distinct\_implementation](/docs/reference/settings/session-settings/count-distinct#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:

```sql theme={null}
SELECT SUM(-1), MAX(0) FROM system.one WHERE 0;
```

With `aggregate_functions_null_for_empty = 0` it would produce:

```text theme={null}
┌─SUM(-1)─┬─MAX(0)─┐
│       0 │      0 │
└─────────┴────────┘
```

With `aggregate_functions_null_for_empty = 1` the result would be:

```text theme={null}
┌─SUMOrNull(-1)─┬─MAXOrNull(0)─┐
│          NULL │         NULL │
└───────────────┴──────────────┘
```
