# Formats

CoordinatorDB reads rows with `INSERT ... FORMAT` and writes query results with
`SELECT ... FORMAT`. A format can support input, output, or both. The default
output format is `pretty_compact`.

Format names are case-insensitive. Use the snake_case names listed below;
ClickHouse CamelCase names are not aliases.

## Formats overview

| Format                                                                                                                                         | Input | Output |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ----- | ------ |
| [arrow](https://coordinatordb.com/docs/reference/formats/arrow/arrow)                                                                          | Yes   | Yes    |
| [arrow_stream](https://coordinatordb.com/docs/reference/formats/arrow/arrow-stream)                                                            | Yes   | Yes    |
| [avro](https://coordinatordb.com/docs/reference/formats/avro/avro)                                                                             | Yes   | Yes    |
| [avro_confluent](https://coordinatordb.com/docs/reference/formats/avro/avro-confluent)                                                         | Yes   | Yes    |
| [bson_each_row](https://coordinatordb.com/docs/reference/formats/bson-each-row)                                                                | Yes   | Yes    |
| [csv](https://coordinatordb.com/docs/reference/formats/csv/csv)                                                                                | Yes   | Yes    |
| [csv_with_names](https://coordinatordb.com/docs/reference/formats/csv/csv-with-names)                                                          | Yes   | Yes    |
| [csv_with_names_and_types](https://coordinatordb.com/docs/reference/formats/csv/csv-with-names-and-types)                                      | Yes   | Yes    |
| [custom_separated](https://coordinatordb.com/docs/reference/formats/custom-separated/custom-separated)                                         | Yes   | Yes    |
| [custom_separated_with_names](https://coordinatordb.com/docs/reference/formats/custom-separated/custom-separated-with-names)                   | Yes   | Yes    |
| [form](https://coordinatordb.com/docs/reference/formats/form)                                                                                  | Yes   | No     |
| [geo_json](https://coordinatordb.com/docs/reference/formats/geo-json)                                                                          | Yes   | Yes    |
| [hash](https://coordinatordb.com/docs/reference/formats/hash)                                                                                  | No    | Yes    |
| [hive_text](https://coordinatordb.com/docs/reference/formats/hive-text)                                                                        | Yes   | Yes    |
| [json](https://coordinatordb.com/docs/reference/formats/json/json)                                                                             | Yes   | Yes    |
| [json_as_object](https://coordinatordb.com/docs/reference/formats/json/json-as-object)                                                         | Yes   | No     |
| [json_as_string](https://coordinatordb.com/docs/reference/formats/json/json-as-string)                                                         | Yes   | No     |
| [json_columns](https://coordinatordb.com/docs/reference/formats/json/json-columns)                                                             | Yes   | Yes    |
| [json_compact](https://coordinatordb.com/docs/reference/formats/json/json-compact)                                                             | No    | Yes    |
| [json_compact_columns](https://coordinatordb.com/docs/reference/formats/json/json-compact-columns)                                             | Yes   | Yes    |
| [json_compact_each_row](https://coordinatordb.com/docs/reference/formats/json/json-compact-each-row)                                           | Yes   | Yes    |
| [json_compact_each_row_with_names_and_types](https://coordinatordb.com/docs/reference/formats/json/json-compact-each-row-with-names-and-types) | Yes   | Yes    |
| [json_compact_strings_each_row](https://coordinatordb.com/docs/reference/formats/json/json-compact-strings-each-row)                           | Yes   | Yes    |
| [json_each_row](https://coordinatordb.com/docs/reference/formats/json/json-each-row)                                                           | Yes   | Yes    |
| [json_object_each_row](https://coordinatordb.com/docs/reference/formats/json/json-object-each-row)                                             | Yes   | Yes    |
| [json_strings_each_row](https://coordinatordb.com/docs/reference/formats/json/json-strings-each-row)                                           | Yes   | Yes    |
| [line_as_string](https://coordinatordb.com/docs/reference/formats/line-as-string/line-as-string)                                               | Yes   | Yes    |
| [markdown](https://coordinatordb.com/docs/reference/formats/markdown)                                                                          | No    | Yes    |
| [msg_pack](https://coordinatordb.com/docs/reference/formats/msg-pack)                                                                          | Yes   | Yes    |
| [npy](https://coordinatordb.com/docs/reference/formats/npy)                                                                                    | Yes   | Yes    |
| [null_output](https://coordinatordb.com/docs/reference/formats/null-output)                                                                    | No    | Yes    |
| [parquet](https://coordinatordb.com/docs/reference/formats/parquet/parquet)                                                                    | Yes   | Yes    |
| [parquet_metadata](https://coordinatordb.com/docs/reference/formats/parquet/parquet-metadata)                                                  | Yes   | No     |
| [png](https://coordinatordb.com/docs/reference/formats/png)                                                                                    | No    | Yes    |
| [pretty_compact](https://coordinatordb.com/docs/reference/formats/pretty/pretty-compact)                                                       | No    | Yes    |
| [protobuf](https://coordinatordb.com/docs/reference/formats/protobuf/protobuf)                                                                 | Yes   | Yes    |
| [regexp](https://coordinatordb.com/docs/reference/formats/regexp)                                                                              | Yes   | No     |
| [row_binary](https://coordinatordb.com/docs/reference/formats/row-binary/row-binary)                                                           | Yes   | Yes    |
| [row_binary_with_names](https://coordinatordb.com/docs/reference/formats/row-binary/row-binary-with-names)                                     | Yes   | Yes    |
| [row_binary_with_names_and_types](https://coordinatordb.com/docs/reference/formats/row-binary/row-binary-with-names-and-types)                 | Yes   | Yes    |
| [sql_insert](https://coordinatordb.com/docs/reference/formats/sql-insert)                                                                      | No    | Yes    |
| [sql_values](https://coordinatordb.com/docs/reference/formats/sql-values)                                                                      | Yes   | Yes    |
| [sqlite](https://coordinatordb.com/docs/reference/formats/sqlite)                                                                              | Yes   | Yes    |
| [tab_separated](https://coordinatordb.com/docs/reference/formats/tab-separated/tab-separated)                                                  | Yes   | Yes    |
| [tab_separated_raw](https://coordinatordb.com/docs/reference/formats/tab-separated/tab-separated-raw)                                          | Yes   | Yes    |
| [tab_separated_with_names](https://coordinatordb.com/docs/reference/formats/tab-separated/tab-separated-with-names)                            | Yes   | Yes    |
| [tab_separated_with_names_and_types](https://coordinatordb.com/docs/reference/formats/tab-separated/tab-separated-with-names-and-types)        | Yes   | Yes    |
| [template](https://coordinatordb.com/docs/reference/formats/template/template)                                                                 | Yes   | Yes    |
| [tskv](https://coordinatordb.com/docs/reference/formats/tab-separated/tskv)                                                                    | Yes   | Yes    |
| [vertical](https://coordinatordb.com/docs/reference/formats/vertical)                                                                          | No    | Yes    |
| [xml](https://coordinatordb.com/docs/reference/formats/xml)                                                                                    | No    | Yes    |
| [yaml](https://coordinatordb.com/docs/reference/formats/yaml)                                                                                  | Yes   | Yes    |

Use [format settings](https://coordinatordb.com/docs/reference/settings/formats) in a statement's `SETTINGS` clause.
These settings apply to one statement and are not persisted by `SET`. On an
`INSERT`, put `SETTINGS` before `FORMAT`: the bytes after the format name are
input data.

## Reading and writing data

Create a destination table:

```sql
CREATE TABLE people (id UInt32, name String);
```

Read two CSV rows in a separate request:

```sql
INSERT INTO people FORMAT csv
1,Ada
2,Grace
```

Write the same rows as one JSON object per line:

```sql
SELECT id, name FROM people ORDER BY id FORMAT json_each_row;
```

```text
{"id":1,"name":"Ada"}
{"id":2,"name":"Grace"}
```

Inline input occupies the rest of its request. Send later SQL in another request.
For client files, see the [loading guide](https://coordinatordb.com/docs/guides/clickhouse/data-formats/intro).

## Format schema

Schema-bearing containers include Arrow, Parquet, Avro, NumPy, and SQLite.
Input values must still satisfy the destination column declarations.

The `protobuf` format uses the statement settings `protobuf_schema` and
`protobuf_message` for its inline schema and message name. The
`avro_confluent` format resolves schema identifiers through its configured
schema registry. See their format pages for complete examples.

A container schema does not replace an explicit server `file()` schema except
for the input formats that support inference or supply fixed metadata columns.
See [file schemas](https://coordinatordb.com/docs/concepts/features/interfaces/schema-inference).
