From 9c5ad1e7736db7239da185bc30c605f25b4a9c01 Mon Sep 17 00:00:00 2001 From: avogar Date: Fri, 6 May 2022 16:51:50 +0000 Subject: [PATCH] Add docs --- docs/en/interfaces/formats.md | 100 ++++++++++++++++++++++++ docs/en/operations/settings/settings.md | 6 ++ 2 files changed, 106 insertions(+) diff --git a/docs/en/interfaces/formats.md b/docs/en/interfaces/formats.md index f21858ccc25..d4a68ca72fa 100644 --- a/docs/en/interfaces/formats.md +++ b/docs/en/interfaces/formats.md @@ -30,8 +30,13 @@ The supported formats are: | [JSON](#json) | ✗ | ✔ | | [JSONAsString](#jsonasstring) | ✔ | ✗ | | [JSONStrings](#jsonstrings) | ✗ | ✔ | +| [JSONColumns](#jsoncolumns) | ✔ | ✔ | +| [JSONColumnsMonoBlock](#jsoncolumnsmonoblock) | ✗ | ✔ | +| [JSONColumnsWithMetadata](#jsoncolumnswithmetadata) | ✗ | ✔ | | [JSONCompact](#jsoncompact) | ✗ | ✔ | | [JSONCompactStrings](#jsoncompactstrings) | ✗ | ✔ | +| [JSONCompactColumns](#jsoncompactcolumns) | ✔ | ✔ | +| [JSONCompactColumnsMonoBlock](#jsoncompactcolumnsmonoblock) | ✗ | ✔ | | [JSONEachRow](#jsoneachrow) | ✔ | ✔ | | [JSONEachRowWithProgress](#jsoneachrowwithprogress) | ✗ | ✔ | | [JSONStringsEachRow](#jsonstringseachrow) | ✔ | ✔ | @@ -565,6 +570,82 @@ Example: } ``` +## JSONColumns {#jsoncolumns} + +In this format, each block of data is represented as a JSON Object: + +```json +{ + "name1": [1, 2, 3, 4], + "name2": ["Hello", ",", "world", "!"], + "name3": [[1, 2], [3, 4], [5, 6], [7, 8]] +} +``` + +Columns with unknown names will be skipped if setting [input_format_skip_unknown_fields](../operations/settings/settings.md#settings-input-format-skip-unknown-fields) is set to 1. +Columns that are not presente in the block will be filled with default values (you can use [input_format_defaults_for_omitted_fields](../operations/settings/settings.md#session_settings-input_format_defaults_for_omitted_fields) setting here) + +## JSONColumnsMonoBlock {#jsoncolumnsmonoblock} + +Differs from JSONColumns in that it buffers up to [output_format_json_columns_max_rows_to_buffer](../operations/settings/settings.md#output-format-json-columns-max-rows-to-buffer) +rows and then outputs them as a single block. + +## JSONColumnsWithMetadata {#jsoncolumnsmonoblock} + +Differs from JSON output format in that it outputs columns as in JSONColumns format. This format buffers up to [output_format_json_columns_max_rows_to_buffer](../operations/settings/settings.md#session_settings-output-format-json-columns-max-rows-to-buffer) +rows and then outputs them as a single block. + +```json +{ + "meta": + [ + { + "name": "sum", + "type": "UInt64" + }, + { + "name": "avg", + "type": "Float64" + } + ], + + "data": + { + "sum": ["1", "2", "3", "4"], + "avg": [1, 2, 3, 2] + }, + + "totals": + { + "sum": "10", + "avg": 2 + }, + + "extremes": + { + "min": + { + "sum": "1", + "avg": 1 + }, + "max": + { + "sum": "4", + "avg": 3 + } + }, + + "rows": 4, + + "statistics": + { + "elapsed": 0.003701718, + "rows_read": 5, + "bytes_read": 20 + } +} +``` + ## JSONAsString {#jsonasstring} In this format, a single JSON object is interpreted as a single value. If the input has several JSON objects (comma separated), they are interpreted as separate rows. If the input data is enclosed in square brackets, it is interpreted as an array of JSONs. @@ -683,6 +764,25 @@ Example: } ``` +## JSONCompactColumns {#jsoncompactcolumns} + +In this format, each block of data is represented as a JSON array of arrays: + +```json +[ + [1, 2, 3, 4], + ["Hello", ",", "world", "!"], + [[1, 2], [3, 4], [5, 6], [7, 8]] +] +``` + +Columns that are not presente in the block will be filled with default values (you can use [input_format_defaults_for_omitted_fields](../operations/settings/settings.md#session_settings-input_format_defaults_for_omitted_fields) setting here) + +## JSONCompactColumnsMonoBlock {#jsoncompactcolumnsmonoblock} + +Differs from JSONCompactColumns in that it buffers up to [output_format_json_columns_max_rows_to_buffer](../operations/settings/settings.md#session_settings-output-format-json-columns-max-rows-to-buffer) +rows and then outputs them as a single block. + ## JSONEachRow {#jsoneachrow} ## JSONStringsEachRow {#jsonstringseachrow} ## JSONCompactEachRow {#jsoncompacteachrow} diff --git a/docs/en/operations/settings/settings.md b/docs/en/operations/settings/settings.md index 8f2b9bc86fc..ef52ab415bf 100644 --- a/docs/en/operations/settings/settings.md +++ b/docs/en/operations/settings/settings.md @@ -3784,6 +3784,12 @@ Possible values: Default value: `0`. +## output_format_json_columns_max_rows_to_buffer {#output-format-json-columns-max-rows-to-buffer} + +The maximum rows to buffer in formats JSONColumnsMonoBlock/JSONCompactColumnsMonoBlock/JSONColumnsWithMetadata + +Default value: `10000`. + ## allow_experimental_projection_optimization {#allow-experimental-projection-optimization} Enables or disables [projection](../../engines/table-engines/mergetree-family/mergetree.md#projections) optimization when processing `SELECT` queries.