mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Init commit
This commit is contained in:
parent
90dcc135b4
commit
0f78dbc31d
@ -6,7 +6,8 @@ toc_priority: 11
|
|||||||
|
|
||||||
# How to Import JSON Into ClickHouse? {#how-to-import-json-into-clickhouse}
|
# How to Import JSON Into ClickHouse? {#how-to-import-json-into-clickhouse}
|
||||||
|
|
||||||
ClickHouse supports a wide range of [data formats for input and output](../../interfaces/formats.md). There are multiple JSON variations among them, but the most commonly used for data ingestion is [JSONEachRow](../../interfaces/formats.md#jsoneachrow). It expects one JSON object per row, each object separated by a newline.
|
ClickHouse supports a wide range of [data formats for input and output](../../interfaces/formats.md). There are multiple JSON variations among them, but the most commonly used for data ingestion is [JSONEachRow](../../interfaces/formats.md#jsoneachrow). It expects one JSON object per row, each object separated by a newline.
|
||||||
|
In JSON format, the presence of quotation marks can determine whether the data is a number or a string. In the case of a number, you must always interpret it as an enum id.
|
||||||
|
|
||||||
## Examples {#examples}
|
## Examples {#examples}
|
||||||
|
|
||||||
|
@ -1167,7 +1167,40 @@ For CSV input format enables or disables parsing of unquoted `NULL` as literal (
|
|||||||
|
|
||||||
## input_format_csv_enum_as_number {#settings-input_format_csv_enum_as_number}
|
## input_format_csv_enum_as_number {#settings-input_format_csv_enum_as_number}
|
||||||
|
|
||||||
For CSV input format switches to parsing enum values as enum ids.
|
Enables or disables to parsing enum values as enum ids for CSV input format.
|
||||||
|
|
||||||
|
Possible values:
|
||||||
|
|
||||||
|
- 0 — Disabled.
|
||||||
|
- 1 — Enabled.
|
||||||
|
|
||||||
|
Default value: 0.
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
Query:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
DROP TABLE IF EXISTS table_with_enum_column_for_csv_insert;
|
||||||
|
|
||||||
|
CREATE TABLE table_with_enum_column_for_csv_insert (Id Int32,Value Enum('ef' = 1, 'es' = 2)) ENGINE=Memory();
|
||||||
|
|
||||||
|
SET input_format_csv_enum_as_number = 1;
|
||||||
|
|
||||||
|
INSERT INTO table_with_enum_column_for_csv_insert FORMAT CSV 102,2;
|
||||||
|
SELECT * FROM table_with_enum_column_for_csv_insert;
|
||||||
|
|
||||||
|
SET input_format_csv_enum_as_number = 0;
|
||||||
|
DROP TABLE IF EXISTS table_with_enum_column_for_csv_insert;
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
```text
|
||||||
|
┌──Id─┬─Value─┐
|
||||||
|
│ 102 │ es │
|
||||||
|
└─────┴───────┘
|
||||||
|
```
|
||||||
|
|
||||||
## output_format_csv_crlf_end_of_line {#settings-output-format-csv-crlf-end-of-line}
|
## output_format_csv_crlf_end_of_line {#settings-output-format-csv-crlf-end-of-line}
|
||||||
|
|
||||||
|
@ -1127,6 +1127,43 @@ SELECT area/period FROM account_orders FORMAT JSON;
|
|||||||
|
|
||||||
Для формата CSV включает или выключает парсинг неэкранированной строки `NULL` как литерала (синоним для `\N`)
|
Для формата CSV включает или выключает парсинг неэкранированной строки `NULL` как литерала (синоним для `\N`)
|
||||||
|
|
||||||
|
## input_format_csv_enum_as_number {#settings-input_format_csv_enum_as_number}
|
||||||
|
|
||||||
|
Включает или отключает парсинг значений перечислений как идентификаторов перечислений для входного формата CSV.
|
||||||
|
|
||||||
|
Возможные значения:
|
||||||
|
|
||||||
|
- 0 — выключена.
|
||||||
|
- 1 — включена.
|
||||||
|
|
||||||
|
Значение по умолчанию: 0.
|
||||||
|
|
||||||
|
**Пример**
|
||||||
|
|
||||||
|
Запрос:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
DROP TABLE IF EXISTS table_with_enum_column_for_csv_insert;
|
||||||
|
|
||||||
|
CREATE TABLE table_with_enum_column_for_csv_insert (Id Int32,Value Enum('ef' = 1, 'es' = 2)) ENGINE=Memory();
|
||||||
|
|
||||||
|
SET input_format_csv_enum_as_number = 1;
|
||||||
|
|
||||||
|
INSERT INTO table_with_enum_column_for_csv_insert FORMAT CSV 102,2;
|
||||||
|
SELECT * FROM table_with_enum_column_for_csv_insert;
|
||||||
|
|
||||||
|
SET input_format_csv_enum_as_number = 0;
|
||||||
|
DROP TABLE IF EXISTS table_with_enum_column_for_csv_insert;
|
||||||
|
```
|
||||||
|
|
||||||
|
Результат:
|
||||||
|
|
||||||
|
```text
|
||||||
|
┌──Id─┬─Value─┐
|
||||||
|
│ 102 │ es │
|
||||||
|
└─────┴───────┘
|
||||||
|
```
|
||||||
|
|
||||||
## output_format_csv_crlf_end_of_line {#settings-output-format-csv-crlf-end-of-line}
|
## output_format_csv_crlf_end_of_line {#settings-output-format-csv-crlf-end-of-line}
|
||||||
|
|
||||||
Использовать в качестве разделителя строк для CSV формата CRLF (DOS/Windows стиль) вместо LF (Unix стиль).
|
Использовать в качестве разделителя строк для CSV формата CRLF (DOS/Windows стиль) вместо LF (Unix стиль).
|
||||||
|
Loading…
Reference in New Issue
Block a user