> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-parallel-read-in-order-multi-part.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# aggregate_* 세션 설정

> aggregate_* 생성 그룹에 속한 ClickHouse 세션 설정입니다.

export const VersionHistory = ({rows = []}) => {
  if (rows.length === 0) {
    return null;
  }
  const headers = ["버전", "기본값", "설명"];
  const border = "1px solid rgba(128, 128, 128, 0.3)";
  const cell = {
    border,
    padding: "0.25rem 0.5rem",
    textAlign: "start",
    verticalAlign: "top"
  };
  return <details className="not-prose" style={{
    border,
    borderRadius: "0.5rem",
    margin: "0.5rem 0",
    padding: "0.5rem 0.75rem",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <summary style={{
    cursor: "pointer",
    fontWeight: 600,
    opacity: 0.72
  }}>
        버전 이력
      </summary>
      <table style={{
    borderCollapse: "collapse",
    width: "100%",
    margin: "0.5rem 0 0"
  }}>
        <thead>
          <tr>
            {headers.map(header => <th key={header} style={{
    ...cell,
    fontWeight: 600,
    opacity: 0.72
  }}>
                {header}
              </th>)}
          </tr>
        </thead>
        <tbody>
          {rows.map((row, row_index) => <tr key={row.id ?? row_index}>
              {(row.items ?? []).map((item, item_index) => <td key={item_index} style={{
    ...cell,
    overflowWrap: "anywhere"
  }}>
                  {item?.label}
                </td>)}
            </tr>)}
        </tbody>
      </table>
    </details>;
};

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
  }}>유형</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>기본값</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          재시작 없이 변경 가능
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

이 설정은 [system.settings](/ko/reference/system-tables/settings)에서 확인할 수 있으며 [소스 코드](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp)에서 자동 생성됩니다.

## aggregate\_function\_input\_format

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.12"},{"label": "state"},{"label": "INSERT 작업 중 AggregateFunction 입력 형식을 제어하는 새로운 설정. 설정 값은 기본적으로 state로 지정됨"}]}]} />

입력 형식이 `AggregateFunction` 타입의 컬럼을 읽는 방식입니다.

가능한 값:

* `state` — 출력 형식이 기록하는 형태 그대로의, 집계 함수의 직렬화된 상태입니다(기본값).
* `value` — 집계 함수 인수의 값이며, 인수가 여러 개이면 인수들의 tuple입니다. 이 값이 집계되어 상태가 만들어집니다.
* `array` — 위 `value` 옵션에서 설명한 값들의 배열입니다. 배열의 모든 원소가 집계되어 상태가 만들어집니다.

`value` 및 `array` 모드에서 포맷은 해당 컬럼을 값 타입의 컬럼처럼 읽습니다. 즉, `AggregateFunction(f, T)`는 `T`로, `AggregateFunction(f, T1, T2)`는 `Tuple(T1, T2)`로, `array` 모드에서는 그 타입의 `Array`로 읽습니다. 값은 해당 포맷이 그 타입에 대해 사용하는 표현 방식으로 기록됩니다. 텍스트 형식에서는 숫자나 문자열, JSON 포맷에서는 JSON 배열, `RowBinary`나 `Native`에서는 해당 타입의 이진 인코딩, `Parquet`에서는 해당 타입의 컬럼과 같은 식입니다. 이는 모든 입력 형식에 적용되며, `Array`, `Tuple`, `Map` 안에 중첩된 `AggregateFunction`에도 적용됩니다.

**예시**

다음과 같은 구조의 테이블이 있다고 가정합니다:

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

`aggregate_function_input_format = 'value'`일 때:

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

```sql theme={null}
INSERT INTO example FORMAT JSONEachRow
{"user_id": 123, "avg_session_length": 456}
```

`aggregate_function_input_format = 'array'`로 설정한 경우:

```sql theme={null}
INSERT INTO example FORMAT CSV
123,"[456,789,101]"
```

```sql theme={null}
INSERT INTO example FORMAT JSONEachRow
{"user_id": 123, "avg_session_length": [456, 789, 101]}
```

참고: `value` 및 `array` 포맷은 삽입 시 값을 생성하고 집계해야 하므로 기본 `state` 포맷보다 느립니다.

## aggregate\_functions\_null\_for\_empty

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

쿼리의 모든 집계 함수에 [-OrNull](/ko/reference/functions/aggregate-functions/combinators#-ornull) 접미사를 추가하도록 재작성하는 기능을 활성화하거나 비활성화합니다. SQL 표준 호환성을 위해 이 설정을 활성화하세요.
이 기능은 일관된 결과를 얻기 위해 쿼리 재작성([count\_distinct\_implementation](/ko/reference/settings/session-settings/count-distinct#count_distinct_implementation) 설정과 유사함) 방식으로 구현되며, 특히 분산 쿼리에서 유용합니다.

가능한 값:

* 0 — 비활성화됨.
* 1 — 활성화됨.

**예시**

다음 집계 함수가 포함된 쿼리를 살펴보겠습니다:

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

`aggregate_functions_null_for_empty = 0`으로 설정하면 다음과 같은 결과가 나옵니다:

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

`aggregate_functions_null_for_empty = 1`로 설정하면 결과는 다음과 같습니다:

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