From 483d415b24077590c12d5477484ecd4938fe00bc Mon Sep 17 00:00:00 2001 From: George Date: Mon, 7 Jun 2021 21:24:26 +0300 Subject: [PATCH] First draft --- docs/en/sql-reference/data-types/array.md | 21 +++++++++++++++ .../nested-data-structures/nested.md | 2 +- docs/en/sql-reference/data-types/nullable.md | 21 +++++++++++++++ docs/en/sql-reference/data-types/tuple.md | 26 +++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/docs/en/sql-reference/data-types/array.md b/docs/en/sql-reference/data-types/array.md index 41e35aaa96f..ced7e399f45 100644 --- a/docs/en/sql-reference/data-types/array.md +++ b/docs/en/sql-reference/data-types/array.md @@ -74,4 +74,25 @@ Received exception from server (version 1.1.54388): Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: There is no supertype for types UInt8, String because some of them are String/FixedString and some of them are not. ``` +It is possible to use `size0` subcolumns that can be read without reading the whole column: + +```sql +CREATE TABLE t_arr (a Array(UInt32)) ENGINE = MergeTree ORDER BY tuple() SETTINGS min_bytes_for_wide_part = 0; + +INSERT INTO t_arr VALUES ([1]) ([]) ([1, 2, 3]) ([1, 2]); + +SELECT a.size0 FROM t_arr; +``` + +Result: + +``` text +┌─a.size0─┐ +│ 1 │ +│ 0 │ +│ 3 │ +│ 2 │ +└─────────┘ +``` + [Original article](https://clickhouse.tech/docs/en/data_types/array/) diff --git a/docs/en/sql-reference/data-types/nested-data-structures/nested.md b/docs/en/sql-reference/data-types/nested-data-structures/nested.md index 302d41c1357..902ae8ef715 100644 --- a/docs/en/sql-reference/data-types/nested-data-structures/nested.md +++ b/docs/en/sql-reference/data-types/nested-data-structures/nested.md @@ -34,7 +34,7 @@ CREATE TABLE test.visits This example declares the `Goals` nested data structure, which contains data about conversions (goals reached). Each row in the ‘visits’ table can correspond to zero or any number of conversions. -Only a single nesting level is supported. Columns of nested structures containing arrays are equivalent to multidimensional arrays, so they have limited support (there is no support for storing these columns in tables with the MergeTree engine). +Arbitrary levels of nesting are supported. Columns of nested structures containing arrays are equivalent to multidimensional arrays, so they have limited support (there is no support for storing these columns in tables with the MergeTree engine). In most cases, when working with a nested data structure, its columns are specified with column names separated by a dot. These columns make up an array of matching types. All the column arrays of a single nested data structure have the same length. diff --git a/docs/en/sql-reference/data-types/nullable.md b/docs/en/sql-reference/data-types/nullable.md index 4207e389734..247129a0cf3 100644 --- a/docs/en/sql-reference/data-types/nullable.md +++ b/docs/en/sql-reference/data-types/nullable.md @@ -41,4 +41,25 @@ SELECT x + y FROM t_null └────────────┘ ``` +It is possible to use `null` subcolumns that can be read without reading the whole column: + +``` sql +CREATE TABLE nullable (`n` Nullable(UInt32)) ENGINE = MergeTree ORDER BY tuple(); + +INSERT INTO nullable VALUES (1) (NULL) (2) (NULL); + +SELECT n.null FROM nullable; +``` + +Result: + +``` text +┌─n.null─┐ +│ 0 │ +│ 1 │ +│ 0 │ +│ 1 │ +└────────┘ +``` + [Original article](https://clickhouse.tech/docs/en/data_types/nullable/) diff --git a/docs/en/sql-reference/data-types/tuple.md b/docs/en/sql-reference/data-types/tuple.md index e396006d957..21b4cc7e0d8 100644 --- a/docs/en/sql-reference/data-types/tuple.md +++ b/docs/en/sql-reference/data-types/tuple.md @@ -47,4 +47,30 @@ SELECT tuple(1, NULL) AS x, toTypeName(x) └──────────┴─────────────────────────────────┘ ``` +It is possible to read elements of named tuples using indexes and names: + +``` sql +CREATE TABLE named_tuples (`a` Tuple(s String, i Int64)) ENGINE = Memory; + +INSERT INTO named_tuples VALUES (('y', 10)), (('x',-10)); + +SELECT a.s FROM named_tuples; + +SELECT a.2 FROM named_tuples; +``` + +Result: + +``` text +┌─a.s─┐ +│ y │ +│ x │ +└─────┘ + +┌─tupleElement(a, 2)─┐ +│ 10 │ +│ -10 │ +└────────────────────┘ +``` + [Original article](https://clickhouse.tech/docs/en/data_types/tuple/)