Other functions

[Edit this page](https://github.com/ClickHouse/ClickHouse/tree/master/docs/en/sql-reference/functions/other-functions.md)

Note

The function documentation below is generated from the `system.functions` system table.

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

Introduced in: v20.1.0

Returns the fully qualified domain name of the ClickHouse server.

**Syntax**

```
FQDN()
```

**Aliases**: `fullHostName`

**Arguments**

- None.

**Returned value**

Returns the fully qualified domain name of the ClickHouse server. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT fqdn()
```

```
┌─FQDN()──────────────────────────┐
│ clickhouse.us-east-2.internal │
└─────────────────────────────────┘
```

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

Introduced in: v1.1.0

Interprets a [`UInt64`](/docs/sql-reference/data-types/int-uint) number as a MAC address in big endian format.
Returns the corresponding MAC address in format `AA:BB:CC:DD:EE:FF` (colon-separated numbers in hexadecimal form) as string.

**Syntax**

```
MACNumToString(num)
```

**Arguments**

- `num` — UInt64 number. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns a MAC address in format AA:BB:CC:DD:EE:FF. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT MACNumToString(149809441867716) AS mac_address;
```

```
┌─mac_address───────┐
│ 88:00:11:22:33:44 │
└───────────────────┘
```

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

Introduced in: v1.1.0

The inverse function of MACNumToString. If the MAC address has an invalid format, it returns 0.

**Syntax**

```
MACStringToNum(s)
```

**Arguments**

- `s` — MAC address string. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns a UInt64 number. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT MACStringToNum('01:02:03:04:05:06') AS mac_numeric;
```

```
1108152157446
```

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

Introduced in: v1.1.0

Given a MAC address in format AA:BB:CC:DD:EE:FF (colon-separated numbers in hexadecimal form), returns the first three octets as a UInt64 number. If the MAC address has an invalid format, it returns 0.

**Syntax**

```
MACStringToOUI(s)
```

**Arguments**

- `s` — MAC address string. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

First three octets as UInt64 number. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT MACStringToOUI('00:50:56:12:34:56') AS oui;
```

```
20566
```

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

Introduced in: v25.11.0

If the session user has been switched using the EXECUTE AS command, this function returns the name of the original user that was used for authentication and creating the session.
Alias: authUser()

**Syntax**

```
authenticatedUser()
```

**Aliases**: `authUser`

**Arguments**

- None.

**Returned value**

The name of the authenticated user. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
EXECUTE as u1;
            SELECT currentUser(), authenticatedUser();
```

```
┌─currentUser()─┬─authenticatedUser()─┐
│ u1            │ default             │
└───────────────┴─────────────────────┘
```

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

Introduced in: v1.1.0

Builds a bar chart.
Draws a band with width proportional to (x - min) and equal to width characters when x = max.
The band is drawn with accuracy to one eighth of a symbol.

**Syntax**

```
bar(x, min, max[, width])
```

**Arguments**

- `x` — Size to display. [`(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)
- `min` — The minimum value. [`(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)
- `max` — The maximum value. [`(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)
- `width` — Optional. The width of the bar in characters. The default is `80`. [`const (U)Int*`](/docs/sql-reference/data-types/int-uint) or [`const Float*`](/docs/sql-reference/data-types/float) or [`const Decimal`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns a unicode-art bar string. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT
toHour(EventTime) AS h,
count() AS c,
bar(c, 0, 600000, 20) AS bar
FROM test.hits
GROUP BY h
ORDER BY h ASC
```

```
┌──h─┬──────c─┬─bar────────────────┐
│  0 │ 292907 │ █████████▋         │
│  1 │ 180563 │ ██████             │
│  2 │ 114861 │ ███▋               │
│  3 │  85069 │ ██▋                │
│  4 │  68543 │ ██▎                │
│  5 │  78116 │ ██▌                │
│  6 │ 113474 │ ███▋               │
│  7 │ 170678 │ █████▋             │
│  8 │ 278380 │ █████████▎         │
│  9 │ 391053 │ █████████████      │
│ 10 │ 457681 │ ███████████████▎   │
│ 11 │ 493667 │ ████████████████▍  │
│ 12 │ 509641 │ ████████████████▊  │
│ 13 │ 522947 │ █████████████████▍ │
│ 14 │ 539954 │ █████████████████▊ │
│ 15 │ 528460 │ █████████████████▌ │
│ 16 │ 539201 │ █████████████████▊ │
│ 17 │ 523539 │ █████████████████▍ │
│ 18 │ 506467 │ ████████████████▊  │
│ 19 │ 520915 │ █████████████████▎ │
│ 20 │ 521665 │ █████████████████▍ │
│ 21 │ 542078 │ ██████████████████ │
│ 22 │ 493642 │ ████████████████▍  │
│ 23 │ 400397 │ █████████████▎     │
└────┴────────┴────────────────────┘
```

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

Introduced in: v1.1.0

Returns a monotonically increasing sequence number of the [block](/docs/development/architecture#block) containing the row.
The returned block number is updated on a best-effort basis, i.e. it may not be fully accurate.

**Syntax**

```
blockNumber()
```

**Arguments**

- None.

**Returned value**

Sequence number of the data block where the row is located. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Basic usage**

```
SELECT blockNumber()
FROM
(
    SELECT *
    FROM system.numbers
    LIMIT 10
) SETTINGS max_block_size = 2
```

```
┌─blockNumber()─┐
│             7 │
│             7 │
└───────────────┘
┌─blockNumber()─┐
│             8 │
│             8 │
└───────────────┘
┌─blockNumber()─┐
│             9 │
│             9 │
└───────────────┘
┌─blockNumber()─┐
│            10 │
│            10 │
└───────────────┘
┌─blockNumber()─┐
│            11 │
│            11 │
└───────────────┘
```

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

Introduced in: v20.3.0

Returns the uncompressed size in bytes of a block of values on disk.

**Syntax**

```
blockSerializedSize(x1[, x2[, ...]])
```

**Arguments**

- `x1[, x2, ...]` — Any number of values for which to get the uncompressed size of the block. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns the number of bytes that will be written to disk for a block of values without compression. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**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")