> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> RowBinaryWithNamesAndTypesAndDefaults 포맷 문서

# RowBinaryWithNamesAndTypesAndDefaults

| 입력 | 출력 | 별칭 |
| -- | -- | -- |
| ✔  | ✗  |    |

<div id="description">
  ## 설명
</div>

[`RowBinaryWithNamesAndTypes`](/ko/reference/formats/RowBinary/RowBinaryWithNamesAndTypes) 포맷과 유사하지만, 각 셀 앞에 해당 컬럼의 `DEFAULT` 값을 사용해야 하는지를 나타내는 바이트가 추가로 붙습니다. 이는 [`RowBinaryWithDefaults`](/ko/reference/formats/RowBinary/RowBinaryWithDefaults) 포맷과 정확히 동일한 방식입니다. 이 조합은 스키마가 변경되는 `INSERT`를 지원합니다. 즉, writer는 헤더에서 컬럼을 생략할 수 있으며(이 경우 대상 컬럼의 `DEFAULT`가 적용됨), 전송하는 컬럼에 대해서도 개별 셀마다 "컬럼의 `DEFAULT` 사용"으로 표시할 수 있으므로 이를 `NULL`과 혼동하지 않습니다.

이 포맷은 입력 전용입니다.

<div id="wire-format">
  ## Wire 형식
</div>

헤더는 [`RowBinaryWithNamesAndTypes`](/ko/reference/formats/RowBinary/RowBinaryWithNamesAndTypes)와 동일합니다.

1. 컬럼 수 `N`을 나타내는 `VarUInt`
2. 컬럼 이름을 담은 길이 접두사 방식의 `String` `N`개
3. `N`개의 컬럼 타입 — 텍스트 이름 또는 압축 바이너리 인코딩 중 하나이며, `output_format_binary_encode_types_in_binary_format` / `input_format_binary_decode_types_in_binary_format` 설정으로 제어됩니다.

헤더 다음에는 각 행이 `N`개의 셀로 구성됩니다. 각 셀은 다음과 같습니다.

* `UInt8` 마커 바이트 1개
  * `0x01` — 대상 컬럼의 `DEFAULT` 표현식을 사용합니다. 뒤에 값 바이트는 오지 않습니다.
  * `0x00` — 값이 뒤따르며, 컬럼 타입의 `RowBinary` 직렬화기를 사용해 직렬화됩니다. `Nullable(T)`의 경우 값 바이트는 `Nullable` 널 바이트(널이 아니면 `0`, `NULL`이면 `1`)로 시작하고, 널이 아닌 경우 그 뒤에 내부 값이 옵니다.

<div id="defaults-vs-null">
  ## 기본값 vs NULL
</div>

셀별 기본 마커와 `Nullable`의 내장 널 바이트는 서로 독립적으로 동작합니다. `Nullable(UInt32) DEFAULT 42` 컬럼은 각 행마다 세 가지 방식으로 전송될 수 있습니다:

| 바이트       | 의미                                          |
| --------- | ------------------------------------------- |
| `01`      | `DEFAULT 42`를 사용합니다.                        |
| `00 01`   | 값 경로를 따른 뒤 `Nullable` 타입을 통해 `NULL`을 나타냅니다. |
| `00 00 …` | 값 경로를 따른 뒤 null이 아닌 내부 값을 나타냅니다.            |

<div id="schema-evolution">
  ## 스키마 진화
</div>

| Case                       | Behavior                                                                                                                     |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| 파일 헤더에 컬럼이 아예 없음           | `insertDefaultsForNotSeenColumns`를 통해 대상에 기본값이 채워지며, `defaults_for_omitted_fields`의 적용을 받습니다.                                |
| 헤더에 컬럼이 있고, 셀 마커가 `0x01`임  | 각 행에 `insertDefault`가 적용됩니다.                                                                                                 |
| 헤더에 컬럼이 있고, 셀 마커가 `0x00`임  | 값이 정상적으로 파싱됩니다.                                                                                                              |
| 헤더에 추가 컬럼이 있지만 대상 테이블에는 없음 | `input_format_skip_unknown_fields = 1`이면 조용히 삭제됩니다(먼저 마커를 읽습니다. `0x01`이면 그 외에는 아무 작업도 하지 않고, `0x00`이면 타입에 맞는 값을 파싱한 후 버립니다). |

<div id="example-usage">
  ## 사용 예시
</div>

```sql title="Query" theme={null}
SELECT * FROM format(
    'RowBinaryWithNamesAndTypesAndDefaults',
    'x Nullable(UInt32) DEFAULT 42',
    unhex('01' || '0178' || '10' || hex('Nullable(UInt32)') || '01')
);
```

```response title="Response" theme={null}
┌──x─┐
│ 42 │
└────┘
```

* 헤더에는 `Nullable(UInt32)` 타입의 `x`라는 컬럼이 하나 있습니다.
* 단일 셀은 `0x01` 마커를 사용하며, 이는 "`DEFAULT 42`를 사용"함을 의미합니다.

<div id="format-settings">
  ## 포맷 설정
</div>

다음 설정은 모든 `RowBinary` 계열 포맷에 공통으로 적용됩니다.

| 설정                                                                                                                                       | 설명                                                                                                                                                                                                             | 기본값     |
| ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| [`format_binary_max_string_size`](/ko/reference/settings/formats#format_binary_max_string_size)                                          | `RowBinary` 포맷에서 `String`에 허용되는 최대 크기입니다.                                                                                                                                                                      | `1GiB`  |
| [`output_format_binary_encode_types_in_binary_format`](/ko/reference/settings/formats#input_format_binary_decode_types_in_binary_format) | [`RowBinaryWithNamesAndTypes`](/ko/reference/formats/RowBinary/RowBinaryWithNamesAndTypes) 출력 형식에서 헤더의 타입을 타입 이름 문자열 대신 [`binary encoding`](/ko/reference/data-types/data-types-binary-encoding)으로 기록할 수 있습니다. | `false` |
| [`input_format_binary_decode_types_in_binary_format`](/ko/reference/settings/formats#input_format_binary_decode_types_in_binary_format)  | [`RowBinaryWithNamesAndTypes`](/ko/reference/formats/RowBinary/RowBinaryWithNamesAndTypes) 입력 형식에서 헤더의 타입을 타입 이름 문자열 대신 [`binary encoding`](/ko/reference/data-types/data-types-binary-encoding)으로 읽을 수 있습니다.  | `false` |
| [`output_format_binary_write_json_as_string`](/ko/reference/settings/formats#output_format_binary_write_json_as_string)                  | [`RowBinary`](/ko/reference/formats/RowBinary/RowBinary) 출력 형식에서 [`JSON`](/ko/reference/data-types/newjson) 데이터 타입의 값을 `JSON` [String](/ko/reference/data-types/string) 값으로 기록할 수 있습니다.                        | `false` |
| [`input_format_binary_read_json_as_string`](/ko/reference/settings/formats#input_format_binary_read_json_as_string)                      | [`RowBinary`](/ko/reference/formats/RowBinary/RowBinary) 입력 형식에서 [`JSON`](/ko/reference/data-types/newjson) 데이터 타입의 값을 `JSON` [String](/ko/reference/data-types/string) 값으로 읽을 수 있습니다.                         | `false` |
