mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-19 23:10:50 +00:00
67c2e50331
* update presentations * CLICKHOUSE-2936: redirect from clickhouse.yandex.ru and clickhouse.yandex.com * update submodule * lost files * CLICKHOUSE-2981: prefer sphinx docs over original reference * CLICKHOUSE-2981: docs styles more similar to main website + add flags to switch language links * update presentations * Less confusing directory structure (docs -> doc/reference/) * Minify sphinx docs too * Website release script: fail fast + pass docker hash on deploy * Do not underline links in docs * shorter * cleanup docker images * tune nginx config * CLICKHOUSE-3043: get rid of habrastorage links * Lost translation * CLICKHOUSE-2936: temporary client-side redirect * behaves weird in test * put redirect back * CLICKHOUSE-3047: copy docs txts to public too * move to proper file * remove old pages to avoid confusion * Remove reference redirect warning for now * Refresh README.md * Yellow buttons in docs * Use svg flags instead of unicode ones in docs * fix test website instance * Put flags to separate files * wrong flag * Copy Yandex.Metrica introduction from main page to docs * Yet another home page structure change, couple new blocks (CLICKHOUSE-3045) * Update Contacts section * CLICKHOUSE-2849: more detailed legal information * CLICKHOUSE-2978 preparation - split by files * More changes in Contacts block * Tune texts on index page * update presentations * One more benchmark * Add usage sections to index page, adapted from slides * Get the roadmap started, based on slides from last ClickHouse Meetup * CLICKHOUSE-2977: some rendering tuning * Get rid of excessive section in the end of getting started * Make headers linkable * CLICKHOUSE-2981: links to editing reference - https://github.com/yandex/ClickHouse/issues/849 * CLICKHOUSE-2981: fix mobile styles in docs * Ban crawling of duplicating docs * Open some external links in new tab * Ban old docs too * Lots of trivial fixes in english docs * Lots of trivial fixes in russian docs * Remove getting started copies in markdown * Add Yandex.Webmaster * Fix some sphinx warnings * More warnings fixed in english docs * More sphinx warnings fixed * Add code-block:: text * More code-block:: text * These headers look not that well * Better switch between documentation languages * merge use_case.rst into ya_metrika_task.rst * Edit the agg_functions.rst texts * Add lost empty lines * Lost blank lines * Add new logo sizes * update presentations * Next step in migrating to new documentation * Fix all warnings in en reference * Fix all warnings in ru reference * Re-arrange existing reference * Move operation tips to main reference * Fix typos noticed by milovidov@ * Get rid of zookeeper.md * Looks like duplicate of tutorial.html * Fix some mess with html tags in tutorial * No idea why nobody noticed this before, but it was completely not clear whet to get the data * Match code block styling between main and tutorial pages (in favor of the latter) * Get rid of some copypaste in tutorial * Normalize header styles * Move example_datasets to sphinx * Move presentations submodule to website * Move and update README.md * No point in duplicating articles from habrahabr here * Move development-related docs as is for now * doc/reference/ -> docs/ (to match the URL on website) * Adapt links to match the previous commit * Adapt development docs to rst (still lacks translation and strikethrough support) * clean on release * blacklist presentations in gulp * strikethrough support in sphinx * just copy development folder for now * fix weird introduction in style article * Style guide translation (WIP) * Finish style guide translation to English * gulp clean separately * Update year in LICENSE * Initial CONTRIBUTING.md * Fix remaining links to old docs in tutorial * Some tutorial fixes * Typo * Another typo * Update list of authors from yandex-team accoding to git log
99 lines
6.8 KiB
ReStructuredText
99 lines
6.8 KiB
ReStructuredText
Nested(Name1 Type1, Name2 Type2, ...)
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
Вложенная структура данных - это как будто вложенная таблица. Параметры вложенной структуры данных - имена и типы столбцов, указываются так же, как в запроса CREATE. Каждой строке таблицы может соответствовать произвольное количество строк вложенной структуры данных.
|
||
|
||
Пример:
|
||
|
||
.. code-block:: sql
|
||
|
||
CREATE TABLE test.visits
|
||
(
|
||
CounterID UInt32,
|
||
StartDate Date,
|
||
Sign Int8,
|
||
IsNew UInt8,
|
||
VisitID UInt64,
|
||
UserID UInt64,
|
||
...
|
||
Goals Nested
|
||
(
|
||
ID UInt32,
|
||
Serial UInt32,
|
||
EventTime DateTime,
|
||
Price Int64,
|
||
OrderID String,
|
||
CurrencyID UInt32
|
||
),
|
||
...
|
||
) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign)
|
||
|
||
В этом примере объявлена вложенная структура данных ``Goals``, содержащая данные о достижении целей. Каждой строке таблицы visits может соответствовать от нуля до произвольного количества достижений целей.
|
||
|
||
Поддерживается только один уровень вложенности. Столбцы вложенных структур, содержащие массивы, эквивалентны многомерным массивам, поэтому их поддержка ограничена (не поддерживается хранение таких столбцов в таблицах с движком семейства MergeTree).
|
||
|
||
В большинстве случаев, при работе с вложенной структурой данных, указываются отдельные её столбцы. Для этого, имена столбцов указываются через точку. Эти столбцы представляют собой массивы соответствующих типов. Все столбцы-массивы одной вложенной структуры данных имеют одинаковые длины.
|
||
|
||
Пример:
|
||
|
||
.. code-block:: sql
|
||
|
||
SELECT
|
||
Goals.ID,
|
||
Goals.EventTime
|
||
FROM test.visits
|
||
WHERE CounterID = 101500 AND length(Goals.ID) < 5
|
||
LIMIT 10
|
||
|
||
.. code-block:: text
|
||
|
||
┌─Goals.ID───────────────────────┬─Goals.EventTime───────────────────────────────────────────────────────────────────────────┐
|
||
│ [1073752,591325,591325] │ ['2014-03-17 16:38:10','2014-03-17 16:38:48','2014-03-17 16:42:27'] │
|
||
│ [1073752] │ ['2014-03-17 00:28:25'] │
|
||
│ [1073752] │ ['2014-03-17 10:46:20'] │
|
||
│ [1073752,591325,591325,591325] │ ['2014-03-17 13:59:20','2014-03-17 22:17:55','2014-03-17 22:18:07','2014-03-17 22:18:51'] │
|
||
│ [] │ [] │
|
||
│ [1073752,591325,591325] │ ['2014-03-17 11:37:06','2014-03-17 14:07:47','2014-03-17 14:36:21'] │
|
||
│ [] │ [] │
|
||
│ [] │ [] │
|
||
│ [591325,1073752] │ ['2014-03-17 00:46:05','2014-03-17 00:46:05'] │
|
||
│ [1073752,591325,591325,591325] │ ['2014-03-17 13:28:33','2014-03-17 13:30:26','2014-03-17 18:51:21','2014-03-17 18:51:45'] │
|
||
└────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
Проще всего понимать вложенную структуру данных, как набор из нескольких столбцов-массивов одинаковых длин.
|
||
|
||
Единственное место, где в запросе SELECT можно указать имя целой вложенной структуры данных, а не отдельных столбцов - секция ARRAY JOIN. Подробнее см. раздел "Секция ARRAY JOIN". Пример:
|
||
|
||
.. code-block:: sql
|
||
|
||
SELECT
|
||
Goal.ID,
|
||
Goal.EventTime
|
||
FROM test.visits
|
||
ARRAY JOIN Goals AS Goal
|
||
WHERE CounterID = 101500 AND length(Goals.ID) < 5
|
||
LIMIT 10
|
||
|
||
.. code-block:: text
|
||
|
||
┌─Goal.ID─┬──────Goal.EventTime─┐
|
||
│ 1073752 │ 2014-03-17 16:38:10 │
|
||
│ 591325 │ 2014-03-17 16:38:48 │
|
||
│ 591325 │ 2014-03-17 16:42:27 │
|
||
│ 1073752 │ 2014-03-17 00:28:25 │
|
||
│ 1073752 │ 2014-03-17 10:46:20 │
|
||
│ 1073752 │ 2014-03-17 13:59:20 │
|
||
│ 591325 │ 2014-03-17 22:17:55 │
|
||
│ 591325 │ 2014-03-17 22:18:07 │
|
||
│ 591325 │ 2014-03-17 22:18:51 │
|
||
│ 1073752 │ 2014-03-17 11:37:06 │
|
||
└─────────┴─────────────────────┘
|
||
|
||
Вы не можете сделать SELECT целой вложенной структуры данных. Можно лишь явно перечислить отдельные столбцы - её составляющие.
|
||
|
||
При запросе INSERT, вы должны передать все составляющие столбцы-массивы вложенной структуры данных по-отдельности (как если бы это были отдельные столбцы-массивы). При вставке проверяется, что они имеют одинаковые длины.
|
||
|
||
При запросе DESCRIBE, столбцы вложенной структуры данных перечисляются так же по отдельности.
|
||
|
||
Работоспособность запроса ALTER для элементов вложенных структур данных, является сильно ограниченной.
|