mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-19 15:01:03 +00:00
2d2bc052e1
* Typo fix. * Links fix. * Fixed links in docs. * More fixes. * docs/en: cleaning some files * docs/en: cleaning data_types * docs/en: cleaning database_engines * docs/en: cleaning development * docs/en: cleaning getting_started * docs/en: cleaning interfaces * docs/en: cleaning operations * docs/en: cleaning query_lamguage * docs/en: cleaning en * docs/ru: cleaning data_types * docs/ru: cleaning index * docs/ru: cleaning database_engines * docs/ru: cleaning development * docs/ru: cleaning general * docs/ru: cleaning getting_started * docs/ru: cleaning interfaces * docs/ru: cleaning operations * docs/ru: cleaning query_language * docs: cleaning interfaces/http * Update docs/en/data_types/array.md decorated ``` Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/nyc_taxi.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/ontime.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/interfaces/formats.md fixed error Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/custom_partitioning_key.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/dicts/external_dicts_dict_sources.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/date_time_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/jdbc.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * docs: fixed error * docs: fixed error
46 lines
1.8 KiB
Markdown
46 lines
1.8 KiB
Markdown
|
|
# Tuple(T1, T2, ...)
|
|
|
|
A tuple of elements, each having an individual [type](index.md#data_types).
|
|
|
|
Tuples 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) and [Higher order functions](../query_language/functions/higher_order_functions.md).
|
|
|
|
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:
|
|
|
|
```sql
|
|
tuple(T1, T2, ...)
|
|
```
|
|
|
|
Example of creating a tuple:
|
|
|
|
```sql
|
|
SELECT tuple(1,'a') AS x, toTypeName(x)
|
|
```
|
|
```text
|
|
┌─x───────┬─toTypeName(tuple(1, 'a'))─┐
|
|
│ (1,'a') │ Tuple(UInt8, String) │
|
|
└─────────┴───────────────────────────┘
|
|
```
|
|
|
|
## 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).
|
|
|
|
Example of automatic data type detection:
|
|
|
|
```sql
|
|
SELECT tuple(1, NULL) AS x, toTypeName(x)
|
|
```
|
|
```text
|
|
┌─x────────┬─toTypeName(tuple(1, NULL))──────┐
|
|
│ (1,NULL) │ Tuple(UInt8, Nullable(Nothing)) │
|
|
└──────────┴─────────────────────────────────┘
|
|
```
|
|
|
|
|
|
[Original article](https://clickhouse.yandex/docs/en/data_types/tuple/) <!--hide-->
|