Update docs about formats

This commit is contained in:
hcz 2020-09-01 17:48:03 +08:00
parent c25a99aaf5
commit 6d37c9d2a6

View File

@ -26,7 +26,10 @@ The supported formats are:
| [VerticalRaw](#verticalraw) | ✗ | ✔ | | [VerticalRaw](#verticalraw) | ✗ | ✔ |
| [JSON](#json) | ✗ | ✔ | | [JSON](#json) | ✗ | ✔ |
| [JSONCompact](#jsoncompact) | ✗ | ✔ | | [JSONCompact](#jsoncompact) | ✗ | ✔ |
| [JSONStrings](#jsonstrings) | ✗ | ✔ |
| [JSONEachRow](#jsoneachrow) | ✔ | ✔ | | [JSONEachRow](#jsoneachrow) | ✔ | ✔ |
| [JSONCompactEachRow](#jsoncompacteachrow) | ✔ | ✔ |
| [JSONStringsEachRow](#jsonstringseachrow) | ✔ | ✔ |
| [TSKV](#tskv) | ✔ | ✔ | | [TSKV](#tskv) | ✔ | ✔ |
| [Pretty](#pretty) | ✗ | ✔ | | [Pretty](#pretty) | ✗ | ✔ |
| [PrettyCompact](#prettycompact) | ✗ | ✔ | | [PrettyCompact](#prettycompact) | ✗ | ✔ |
@ -470,7 +473,7 @@ See also the [JSONEachRow](#jsoneachrow) format.
## JSONCompact {#jsoncompact} ## JSONCompact {#jsoncompact}
Differs from JSON only in that data rows are output in arrays, not in objects. Differs from JSON only in that data rows are output in arrays of any element type, not in objects.
Example: Example:
@ -514,17 +517,26 @@ Example:
This format is only appropriate for outputting a query result, but not for parsing (retrieving data to insert in a table). This format is only appropriate for outputting a query result, but not for parsing (retrieving data to insert in a table).
See also the `JSONEachRow` format. See also the `JSONEachRow` format.
## JSONEachRow {#jsoneachrow} ## JSONStrings {#jsonstrings}
When using this format, ClickHouse outputs rows as separated, newline-delimited JSON objects, but the data as a whole is not valid JSON. Differs from JSON and JSONCompact only in that data rows are output in arrays of strings.
This format is only appropriate for outputting a query result, but not for parsing (retrieving data to insert in a table).
See also the `JSONEachRow` format.
## JSONEachRow {#jsoneachrow}
## JSONCompactEachRow {#jsoncompacteachrow}
## JSONStringsEachRow {#jsonstringseachrow}
When using these formats, ClickHouse outputs rows as separated, newline-delimited JSON values, but the data as a whole is not valid JSON.
``` json ``` json
{"SearchPhrase":"curtain designs","count()":"1064"} {"some_int":42,"some_str":"hello","some_tuple":[1,"a"]} // JSONEachRow
{"SearchPhrase":"baku","count()":"1000"} [42,"hello",[1,"a"]] // JSONCompactEachRow
{"SearchPhrase":"","count()":"8267016"} ["42","hello","(2,'a')"] // JSONStringsEachRow
``` ```
When inserting the data, you should provide a separate JSON object for each row. When inserting the data, you should provide a separate JSON value for each row.
### Inserting Data {#inserting-data} ### Inserting Data {#inserting-data}