mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-19 15:01:03 +00:00
5da33f04c9
* Update of english version of descriprion of the table function `file`. * New syntax for ReplacingMergeTree. Some improvements in text. * Significantly change article about SummingMergeTree. Article is restructured, text is changed in many places of the document. New syntax for table creation is described. * Descriptions of AggregateFunction and AggregatingMergeTree are updated. Russian version. * New syntax for new syntax of CREATE TABLE * Added english docs on Aggregating, Replacing and SummingMergeTree. * CollapsingMergeTree docs. English version. * 1. Update of CollapsingMergeTree. 2. Minor changes in markup * Update aggregatefunction.md * Update aggregatefunction.md * Update aggregatefunction.md * Update aggregatingmergetree.md * GraphiteMergeTree docs update. New syntax for creation of Replicated* tables. Minor changes in *MergeTree tables creation syntax. * Markup fix * Markup and language fixes * Clarification in the CollapsingMergeTree article * DOCAPI-4821. Sync between ru and en versions of docs. * Fixed the ambiguity in geo functions description. * Example of JOIN in ru docs * Deleted misinforming example. * Fixed links to IN operators.
57 lines
2.1 KiB
Markdown
57 lines
2.1 KiB
Markdown
<a name="data_type-tuple"></a>
|
|
|
|
# Tuple(T1, T2, ...)
|
|
|
|
A tuple of elements, each having an individual [type](index.md#data_types).
|
|
|
|
You can't store tuples in tables (other than Memory tables). They are used for temporary column grouping. Columns can be grouped when an IN expression is used in a query, and for specifying certain formal parameters of lambda functions. For more information, see the sections [IN operators](../query_language/select.md#query_language-in_operators) and [Higher order functions](../query_language/functions/higher_order_functions.md#higher_order_functions).
|
|
|
|
Tuples can be the result of a query. In this case, for text formats other than JSON, values are comma-separated in brackets. In JSON formats, tuples are output as arrays (in square brackets).
|
|
|
|
## Creating a tuple
|
|
|
|
You can use a function to create a tuple:
|
|
|
|
```
|
|
tuple(T1, T2, ...)
|
|
```
|
|
|
|
Example of creating a tuple:
|
|
|
|
```
|
|
:) SELECT tuple(1,'a') AS x, toTypeName(x)
|
|
|
|
SELECT
|
|
(1, 'a') AS x,
|
|
toTypeName(x)
|
|
|
|
┌─x───────┬─toTypeName(tuple(1, 'a'))─┐
|
|
│ (1,'a') │ Tuple(UInt8, String) │
|
|
└─────────┴───────────────────────────┘
|
|
|
|
1 rows in set. Elapsed: 0.021 sec.
|
|
```
|
|
|
|
## Working with data types
|
|
|
|
When creating a tuple on the fly, ClickHouse automatically detects the type of each argument as the minimum of the types which can store the argument value. If the argument is [NULL](../query_language/syntax.md#null-literal), the type of the tuple element is [Nullable](nullable.md#data_type-nullable).
|
|
|
|
Example of automatic data type detection:
|
|
|
|
```
|
|
SELECT tuple(1, NULL) AS x, toTypeName(x)
|
|
|
|
SELECT
|
|
(1, NULL) AS x,
|
|
toTypeName(x)
|
|
|
|
┌─x────────┬─toTypeName(tuple(1, NULL))──────┐
|
|
│ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │
|
|
└──────────┴─────────────────────────────────┘
|
|
|
|
1 rows in set. Elapsed: 0.002 sec.
|
|
```
|
|
|
|
|
|
[Original article](https://clickhouse.yandex/docs/en/data_types/tuple/) <!--hide-->
|