Other functions

**Returned value**

Returns the corresponding value from `array_to` if x matches an element in `array_from`, otherwise returns default (if provided) or x (if default not provided). [`Any`](/docs/sql-reference/data-types)

**Examples**

**transform(T, Array(T), Array(U), U) -> U**

```
SELECT
transform(SearchEngineID, [2, 3], ['Yandex', 'Google'], 'Other') AS title,
count() AS c
FROM test.hits
WHERE SearchEngineID != 0
GROUP BY title
ORDER BY c DESC
```

```
┌─title─────┬──────c─┐
│ Yandex    │ 498635 │
│ Google    │ 229872 │
│ Other     │ 104472 │
└───────────┴────────┘
```

**transform(T, Array(T), Array(T)) -> T**

```
SELECT
transform(domain(Referer), ['yandex.ru', 'google.ru', 'vkontakte.ru'], ['www.yandex', 'example.com', 'vk.com']) AS s, count() AS c
FROM test.hits
GROUP BY domain(Referer)
ORDER BY count() DESC
LIMIT 10
```

```
┌─s──────────────┬───────c─┐
│                │ 2906259 │
│ www.yandex     │  867767 │
│ ███████.ru     │  313599 │
│ mail.yandex.ru │  107147 │
│ ██████.ru      │  100355 │
│ █████████.ru   │   65040 │
│ news.yandex.ru │   64515 │
│ ██████.net     │   59141 │
│ example.com    │   57316 │
└────────────────┴─────────┘
```

## uniqThetaIntersect[​](#uniqThetaIntersect "Direct link to uniqThetaIntersect")

Introduced in: v22.9.0

Two uniqThetaSketch objects to do intersect calculation(set operation ∩), the result is a new uniqThetaSketch.

**Syntax**

```
uniqThetaIntersect(uniqThetaSketch,uniqThetaSketch)
```

**Arguments**

- `uniqThetaSketch` — uniqThetaSketch object. [`Tuple`](/docs/sql-reference/data-types/tuple) or [`Array`](/docs/sql-reference/data-types/array) or [`Date`](/docs/sql-reference/data-types/date) or [`DateTime`](/docs/sql-reference/data-types/datetime) or [`String`](/docs/sql-reference/data-types/string) or [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal`](/docs/sql-reference/data-types/decimal)

**Returned value**

A new uniqThetaSketch containing the intersect result. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT finalizeAggregation(uniqThetaIntersect(a, b)) AS a_intersect_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality
FROM
(SELECT arrayReduce('uniqThetaState', [1, 2]) AS a, arrayReduce('uniqThetaState', [2, 3, 4]) AS b);
```

```
┌─a_intersect_b─┬─a_cardinality─┬─b_cardinality─┐
│             1 │             2 │             3 │
└───────────────┴───────────────┴───────────────┘
```

## uniqThetaNot[​](#uniqThetaNot "Direct link to uniqThetaNot")

Introduced in: v22.9.0

Two uniqThetaSketch objects to do a\_not\_b calculation(set operation ×), the result is a new uniqThetaSketch.

**Syntax**

```
uniqThetaNot(uniqThetaSketch,uniqThetaSketch)
```

**Arguments**

- `uniqThetaSketch` — uniqThetaSketch object. [`Tuple`](/docs/sql-reference/data-types/tuple) or [`Array`](/docs/sql-reference/data-types/array) or [`Date`](/docs/sql-reference/data-types/date) or [`DateTime`](/docs/sql-reference/data-types/datetime) or [`String`](/docs/sql-reference/data-types/string) or [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns a new uniqThetaSketch containing the a\_not\_b result. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT finalizeAggregation(uniqThetaNot(a, b)) AS a_not_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality
FROM
(SELECT arrayReduce('uniqThetaState', [2, 3, 4]) AS a, arrayReduce('uniqThetaState', [1, 2]) AS b);
```

```
┌─a_not_b─┬─a_cardinality─┬─b_cardinality─┐
│       2 │             3 │             2 │
└─────────┴───────────────┴───────────────┘
```

## uniqThetaUnion[​](#uniqThetaUnion "Direct link to uniqThetaUnion")

Introduced in: v22.9.0

Two uniqThetaSketch objects to do union calculation(set operation ∪), the result is a new uniqThetaSketch.

**Syntax**

```
uniqThetaUnion(uniqThetaSketch,uniqThetaSketch)
```

**Arguments**

- `uniqThetaSketch` — uniqThetaSketch object. [`Tuple`](/docs/sql-reference/data-types/tuple) or [`Array`](/docs/sql-reference/data-types/array) or [`Date`](/docs/sql-reference/data-types/date) or [`DateTime`](/docs/sql-reference/data-types/datetime) or [`String`](/docs/sql-reference/data-types/string) or [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns a new uniqThetaSketch containing the union result. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT finalizeAggregation(uniqThetaUnion(a, b)) AS a_union_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality
FROM
(SELECT arrayReduce('uniqThetaState', [1, 2]) AS a, arrayReduce('uniqThetaState', [2, 3, 4]) AS b);
```

```
┌─a_union_b─┬─a_cardinality─┬─b_cardinality─┐
│         4 │             2 │             3 │
└───────────┴───────────────┴───────────────┘
```

## uptime[​](#uptime "Direct link to uptime")

Introduced in: v1.1.0

Returns the server's uptime in seconds.
If executed in the context of a distributed table, this function generates a normal column with values relevant to each shard.
Otherwise it produces a constant value.

**Syntax**

```
uptime()
```

**Arguments**

- None.

**Returned value**

Returns the server uptime in seconds. [`UInt32`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT uptime() AS Uptime
```

```
┌─Uptime─┐
│  55867 │
└────────┘
```

## variantElement[​](#variantElement "Direct link to variantElement")

Introduced in: v25.2.0

Extracts a column with specified type from a `Variant` column.

**Syntax**

```
variantElement(variant, type_name[, default_value])
```

**Arguments**

- `variant` — Variant column. [`Variant`](/docs/sql-reference/data-types/variant)
- `type_name` — The name of the variant type to extract. [`String`](/docs/sql-reference/data-types/string)
- `default_value` — The default value that will be used if variant doesn't have variant with specified type. Can be any type. Optional. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns a column with the specified variant type extracted from the Variant column. [`Any`](/docs/sql-reference/data-types)

**Examples**

**Usage example**

```
CREATE TABLE test (v Variant(UInt64, String, Array(UInt64))) ENGINE = Memory;
INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]);
SELECT v, variantElement(v, 'String'), variantElement(v, 'UInt64'), variantElement(v, 'Array(UInt64)') FROM test;
```

```
┌─v─────────────┬─variantElement(v, 'String')─┬─variantElement(v, 'UInt64')─┬─variantElement(v, 'Array(UInt64)')─┐
│ ᴺᵁᴸᴸ          │ ᴺᵁᴸᴸ                        │                        ᴺᵁᴸᴸ │ []                                 │
│ 42            │ ᴺᵁᴸᴸ                        │                          42 │ []                                 │
│ Hello, World! │ Hello, World!               │                        ᴺᵁᴸᴸ │ []                                 │
│ [1,2,3]       │ ᴺᵁᴸᴸ                        │                        ᴺᵁᴸᴸ │ [1,2,3]                            │
└───────────────┴─────────────────────────────┴─────────────────────────────┴────────────────────────────────────┘
```

## variantType[​](#variantType "Direct link to variantType")

Introduced in: v24.2.0

Returns the variant type name for each row of `Variant` column. If row contains NULL, it returns 'None' for it.

**Syntax**

```
variantType(variant)
```

**Arguments**

- `variant` — Variant column. [`Variant`](/docs/sql-reference/data-types/variant)

**Returned value**

Returns an Enum column with variant type name for each row. [`Enum`](/docs/sql-reference/data-types/enum)

**Examples**

**Usage example**

```
CREATE TABLE test (v Variant(UInt64, String, Array(UInt64))) ENGINE = Memory;
INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]);
SELECT variantType(v) FROM test;
```