> ## 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.

> Documentation for the RowBinaryWithNamesAndTypesAndDefaults format

# RowBinaryWithNamesAndTypesAndDefaults

| Input | Output | Alias |
| - | - | - |
| ✔ | ✗ | |

<h2 id="description">
  Description
</h2>

Similar to the [`RowBinaryWithNamesAndTypes`](/reference/formats/RowBinary/RowBinaryWithNamesAndTypes) format, but with an extra byte before each cell that indicates whether the column's `DEFAULT` value should be used — exactly like in the [`RowBinaryWithDefaults`](/reference/formats/RowBinary/RowBinaryWithDefaults) format. This combination supports schema-evolving `INSERT`s: the writer can omit columns from the header (they receive the target column's `DEFAULT`) and, for any column it does send, it can mark individual cells as "use the column's `DEFAULT`" without conflating that with `NULL`.

This format is input only.

<h2 id="wire-format">
  Wire format
</h2>

The header is identical to [`RowBinaryWithNamesAndTypes`](/reference/formats/RowBinary/RowBinaryWithNamesAndTypes):

1. A `VarUInt` with the number of columns `N`.
2. `N` length-prefixed `String`s with column names.
3. `N` column types — either textual names or compact binary encoding, controlled by the `output_format_binary_encode_types_in_binary_format` / `input_format_binary_decode_types_in_binary_format` settings.

After the header, each row consists of `N` cells. For each cell:

* A single `UInt8` marker byte.
  * `0x01` — use the target column's `DEFAULT` expression. No value bytes follow.
  * `0x00` — a value follows, serialized via the column type's `RowBinary` serializer. For `Nullable(T)` the value bytes start with the `Nullable` null byte (`0` for non-null, `1` for NULL), then the inner value if non-null.

<h2 id="defaults-vs-null">
  Defaults vs NULL
</h2>

The per-cell default marker and `Nullable`'s built-in null byte are independent. A `Nullable(UInt32) DEFAULT 42` column can be sent three different ways per row:

| Bytes | Meaning |
| - | - |
| `01` | Use `DEFAULT 42`. |
| `00 01` | Value path, then `NULL` via the `Nullable` type. |
| `00 00 …` | Value path, then a non-null inner value. |

<h2 id="schema-evolution">
  Schema evolution
</h2>

| Case | Behavior |
| - | - |
| Column missing from the file's header entirely | Filled in the target via `insertDefaultsForNotSeenColumns`; gated by `defaults_for_omitted_fields`. |
| Column present in the header, cell marker `0x01` | `insertDefault` per row. |
| Column present in the header, cell marker `0x00` | Value is parsed normally. |
| Extra column in the header, not in the target table | Silently dropped when `input_format_skip_unknown_fields = 1` (the marker is consumed first; if `0x01`, nothing else; if `0x00`, the typed value is parsed and discarded). |

<h2 id="example-usage">
  Example usage
</h2>

```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 │
└────┘
```

* The header carries one column named `x` of type `Nullable(UInt32)`.
* The single cell uses marker `0x01`, meaning "use `DEFAULT 42`".

<h2 id="format-settings">
  Format settings
</h2>

The following settings are common to all `RowBinary` type formats.

| Setting | Description | Default |
| - | - | - |
| [`format_binary_max_string_size`](/reference/settings/formats/format-binary#format_binary_max_string_size) | The maximum allowed size for String in RowBinary format. | `1GiB` |
| [`output_format_binary_encode_types_in_binary_format`](/reference/settings/formats/output-format#output_format_binary_encode_types_in_binary_format) | Allows to write types in header using [`binary encoding`](/reference/data-types/data-types-binary-encoding) instead of strings with type names in [`RowBinaryWithNamesAndTypes`](/reference/formats/RowBinary/RowBinaryWithNamesAndTypes) output format. | `false` |
| [`input_format_binary_decode_types_in_binary_format`](/reference/settings/formats/input-format#input_format_binary_decode_types_in_binary_format) | Allows to read types in header using [`binary encoding`](/reference/data-types/data-types-binary-encoding) instead of strings with type names in [`RowBinaryWithNamesAndTypes`](/reference/formats/RowBinary/RowBinaryWithNamesAndTypes) input format. | `false` |
| [`output_format_binary_write_json_as_string`](/reference/settings/formats/output-format#output_format_binary_write_json_as_string) | Allows to write values of the [`JSON`](/reference/data-types/newjson) data type as `JSON` [String](/reference/data-types/string) values in [`RowBinary`](/reference/formats/RowBinary/RowBinary) output format. | `false` |
| [`input_format_binary_read_json_as_string`](/reference/settings/formats/input-format#input_format_binary_read_json_as_string) | Allows to read values of the [`JSON`](/reference/data-types/newjson) data type as `JSON` [String](/reference/data-types/string) values in [`RowBinary`](/reference/formats/RowBinary/RowBinary) input format. | `false` |
