Other functions

**Examples**

**Usage example**

```
SELECT blockSerializedSize(maxState(1)) AS x;
```

```
┌─x─┐
│ 2 │
└───┘
```

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

Introduced in: v1.1.0

In ClickHouse, queries are processed in [blocks](/docs/development/architecture#block) (chunks).
This function returns the size (row count) of the block the function is called on.

**Syntax**

```
blockSize()
```

**Arguments**

- None.

**Returned value**

Returns the number of rows in the current block. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT blockSize()
FROM system.numbers LIMIT 5
```

```
┌─blockSize()─┐
│           5 │
│           5 │
│           5 │
│           5 │
│           5 │
└─────────────┘
```

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

Introduced in: v20.5.0

Returns the build ID generated by a compiler for the running ClickHouse server binary.
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**

```
buildId()
```

**Arguments**

- None.

**Returned value**

Returns the build ID. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT buildId()
```

```
┌─buildId()────────────────────────────────┐
│ AB668BEF095FAA6BD26537F197AC2AF48A927FB4 │
└──────────────────────────────────────────┘
```

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

Introduced in: v21.1.0

Returns an estimation of the uncompressed byte size of its arguments in memory.
For `String` arguments, the function returns the string length + 8 (length).
If the function has multiple arguments, the function accumulates their byte sizes.

**Syntax**

```
byteSize(arg1[, arg2, ...])
```

**Arguments**

- `arg1[, arg2, ...]` — Values of any data type for which to estimate the uncompressed byte size. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns an estimation of the byte size of the arguments in memory. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT byteSize('string')
```

```
┌─byteSize('string')─┐
│                 15 │
└────────────────────┘
```

**Multiple arguments**

```
SELECT byteSize(NULL, 1, 0.3, '')
```

```
┌─byteSize(NULL, 1, 0.3, '')─┐
│                         19 │
└────────────────────────────┘
```

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

Introduced in: v22.9.0

Evaluate an external catboost model. [CatBoost](https://catboost.ai) is an open-source gradient boosting library developed by Yandex for machine learning.
Accepts a path to a catboost model and model arguments (features).

**Prerequisites**

1. Build the catboost evaluation library

Before evaluating catboost models, the `libcatboostmodel.<so|dylib>` library must be made available. See [CatBoost documentation](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html) how to compile it.

Next, specify the path to `libcatboostmodel.<so|dylib>` in the clickhouse configuration:

```
<clickhouse>
...
    <catboost_lib_path>/path/to/libcatboostmodel.so</catboost_lib_path>
...
</clickhouse>
```

For security and isolation reasons, the model evaluation does not run in the server process but in the clickhouse-library-bridge process.
At the first execution of `catboostEvaluate()`, the server starts the library bridge process if it is not running already. Both processes
communicate using a HTTP interface. By default, port `9012` is used. A different port can be specified as follows - this is useful if port
`9012` is already assigned to a different service.

```
<library_bridge>
    <port>9019</port>
</library_bridge>
```

2. Train a catboost model using libcatboost

See [Training and applying models](https://catboost.ai/docs/features/training.html#training) for how to train catboost models from a training data set.

**Syntax**

```
catboostEvaluate(path_to_model, feature_1[, feature_2, ..., feature_n])
```

**Arguments**

- `path_to_model` — Path to catboost model. [`const String`](/docs/sql-reference/data-types/string)
- `feature` — One or more model features/arguments. [`Float*`](/docs/sql-reference/data-types/float)

**Returned value**

Returns the model evaluation result. [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**catboostEvaluate**

```
SELECT catboostEvaluate('/root/occupy.bin', Temperature, Humidity, Light, CO2, HumidityRatio) AS prediction FROM occupancy LIMIT 1
```

```
4.695691092573497
```

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

Introduced in: v26.2.0

Converts a color from the OKLab perceptual color space to the sRGB color space.

The input color is specified in the OKLab color space. If the input values are outside
the typical OKLab ranges, the result is implementation-defined.

OKLab uses three components:

- L: perceptual lightness (typically in the range [0..1])
- a: green-red opponent axis
- b: blue-yellow opponent axis

The a and b components are theoretically unbounded, but in practice are between -0.4 and 0.4.
OKLab is designed to be perceptually uniform
while remaining inexpensive to compute.

The conversion is intended to be the inverse of colorSRGBToOKLAB and consists of
the following stages:

1. Conversion from OKLab to linear sRGB.
2. Conversion from linear sRGB to gamma-encoded sRGB.

The optional gamma argument specifies the exponent used when converting from linear
sRGB to gamma-encoded RGB values. If not specified, a default gamma value is used
for consistency with colorSRGBToOKLAB.

For more information about the OKLab color space and its relationship to sRGB, see <https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/oklab>
.

**Syntax**

```
colorOKLABToSRGB(tuple [, gamma])
```

**Arguments**

- `tuple` — A tuple of three numeric values `L`, `a`, `b`, where `L` is in the range `[0...1]`. [`Tuple(Float64, Float64, Float64)`](/docs/sql-reference/data-types/tuple)
- `gamma` — Optional. The exponent that is used to transform linear sRGB back to sRGB by applying `(x ^ (1 / gamma)) * 255` for each channel `x`. Defaults to `2.2`. [`Float64`](/docs/sql-reference/data-types/float)

**Returned value**

Returns a tuple (R, G, B) representing sRGB color values. [`Tuple(Float64, Float64, Float64)`](/docs/sql-reference/data-types/tuple)

**Examples**

**Convert OKLAB to sRGB (Float)**

```
SELECT colorOKLABToSRGB((0.4466, 0.0991, 0.44)) AS rgb;
```

```
┌─rgb──────────────────────┐
│ (198.07056923258935,0,0) │
└──────────────────────────┘
```

**Convert OKLAB to sRGB (UInt8)**

```
WITH colorOKLABToSRGB((0.7, 0.1, 0.54)) AS t
SELECT tuple(toUInt8(t.1), toUInt8(t.2), toUInt8(t.3)) AS RGB;
```

```
┌─RGB──────────┐
│ (255,0,0)    │
└──────────────┘
```

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

Introduced in: v25.7.0

Converts a colour from the **OKLCH** perceptual colour space to the familiar **sRGB** colour space.

If `L` is outside the range `[0...1]`, `C` is negative, or `H` is outside the range `[0...360]`, the result is implementation-defined.

Note

**OKLCH** is a cylindrical version of the OKLab colour space.
It's three coordinates are `L` (the lightness in the range `[0...1]`), `C` (chroma `>= 0`) and `H` (hue in degrees from `[0...360]`).
OKLab/OKLCH is designed to be perceptually uniform while remaining cheap to compute.

The conversion is the inverse of [`colorSRGBToOKLCH`](#colorSRGBToOKLCH):

1. OKLCH to OKLab.
2. OKLab to Linear sRGB
3. Linear sRGB to sRGB

The second argument gamma is used at the last stage.

For references of colors in OKLCH space, and how they correspond to sRGB colors please see <https://oklch.com/>.

**Syntax**

```
colorOKLCHToSRGB(tuple [, gamma])
```

**Arguments**