(). In JSON formats, tuples are output as arrays (in []).
Creating Tuples
You can use a function to create a tuple:(tuple_element1, tuple_element2) may be used to create a tuple of several elements without calling the tuple() function.
Example:
Data Type Detection
When creating tuples on the fly, ClickHouse interferes the type of the tuples arguments as the smallest types which can hold the provided argument value. If the value is NULL, the interfered type is Nullable. Example of automatic data type detection:Referring to Tuple Elements
Tuple elements can be referred to by name or by index:Query
Response
Comparison operations with Tuple
Two tuples are compared by sequentially comparing their elements from the left to the right. If first tuples element is greater (smaller) than the second tuples corresponding element, then the first tuple is greater (smaller) than the second, otherwise (both elements are equal), the next element is compared. Example:Nullable(Tuple(T1, T2, …))
Beta FeatureRequires
SET enable_nullable_tuple_type = 1
This is a Beta feature.NULL, as opposed to Tuple(Nullable(T1), Nullable(T2), ...) where only individual elements can be NULL.
| Type | Tuple can be NULL | Elements can be NULL |
|---|---|---|
Nullable(Tuple(String, Int64)) | ✅ | ❌ |
Tuple(Nullable(String), Nullable(Int64)) | ❌ | ✅ |