Other functions

**Arguments**

- `x` — Sequence of characters. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns a 64 bit hash value. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT normalizedQueryHash('SELECT 1 AS `xyz123`') != normalizedQueryHash('SELECT 1 AS `abc123`') AS normalizedQueryHash;
SELECT normalizedQueryHashKeepNames('SELECT 1 AS `xyz123`') != normalizedQueryHashKeepNames('SELECT 1 AS `abc123`') AS normalizedQueryHashKeepNames;
```

```
┌─normalizedQueryHash─┐
│                   0 │
└─────────────────────┘
┌─normalizedQueryHashKeepNames─┐
│                            1 │
└──────────────────────────────┘
```

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

Introduced in: v24.6.0

Given a string containing a byte size and `B`, `KiB`, `KB`, `MiB`, `MB`, etc. as a unit (i.e. [ISO/IEC 80000-13](https://en.wikipedia.org/wiki/ISO/IEC_80000) or decimal byte unit), this function returns the corresponding number of bytes.
If the function is unable to parse the input value, it throws an exception.

The inverse operations of this function are [`formatReadableSize`](#formatReadableSize) and [`formatReadableDecimalSize`](#formatReadableDecimalSize).

**Syntax**

```
parseReadableSize(x)
```

**Arguments**

- `x` — Readable size with ISO/IEC 80000-13 or decimal byte unit. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the number of bytes, rounded up to the nearest integer. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT arrayJoin(['1 B', '1 KiB', '3 MB', '5.314 KiB']) AS readable_sizes, parseReadableSize(readable_sizes) AS sizes;
```

```
┌─readable_sizes─┬───sizes─┐
│ 1 B            │       1 │
│ 1 KiB          │    1024 │
│ 3 MB           │ 3000000 │
│ 5.314 KiB      │    5442 │
└────────────────┴─────────┘
```

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

Introduced in: v24.6.0

Given a string containing a byte size and `B`, `KiB`, `KB`, `MiB`, `MB`, etc. as a unit (i.e. [ISO/IEC 80000-13](https://en.wikipedia.org/wiki/ISO/IEC_80000) or decimal byte unit), this function returns the corresponding number of bytes.
If the function is unable to parse the input value, it returns `NULL`.

The inverse operations of this function are [`formatReadableSize`](#formatReadableSize) and [`formatReadableDecimalSize`](#formatReadableDecimalSize).

**Syntax**

```
parseReadableSizeOrNull(x)
```

**Arguments**

- `x` — Readable size with ISO/IEC 80000-13 or decimal byte unit. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the number of bytes, rounded up to the nearest integer, or `NULL` if unable to parse the input [`Nullable(UInt64)`](/docs/sql-reference/data-types/nullable)

**Examples**

**Usage example**

```
SELECT arrayJoin(['1 B', '1 KiB', '3 MB', '5.314 KiB', 'invalid']) AS readable_sizes, parseReadableSizeOrNull(readable_sizes) AS sizes;
```

```
┌─readable_sizes─┬───sizes─┐
│ 1 B            │       1 │
│ 1 KiB          │    1024 │
│ 3 MB           │ 3000000 │
│ 5.314 KiB      │    5442 │
│ invalid        │    ᴺᵁᴸᴸ │
└────────────────┴─────────┘
```

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

Introduced in: v24.6.0

Given a string containing a byte size and `B`, `KiB`, `KB`, `MiB`, `MB`, etc. as a unit (i.e. [ISO/IEC 80000-13](https://en.wikipedia.org/wiki/ISO/IEC_80000) or decimal byte unit), this function returns the corresponding number of bytes.
If the function is unable to parse the input value, it returns `0`.

The inverse operations of this function are [`formatReadableSize`](#formatReadableSize) and [`formatReadableDecimalSize`](#formatReadableDecimalSize).

**Syntax**

```
parseReadableSizeOrZero(x)
```

**Arguments**

- `x` — Readable size with ISO/IEC 80000-13 or decimal byte unit. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the number of bytes, rounded up to the nearest integer, or `0` if unable to parse the input. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT arrayJoin(['1 B', '1 KiB', '3 MB', '5.314 KiB', 'invalid']) AS readable_sizes, parseReadableSizeOrZero(readable_sizes) AS sizes;
```

```
┌─readable_sizes─┬───sizes─┐
│ 1 B            │       1 │
│ 1 KiB          │    1024 │
│ 3 MB           │ 3000000 │
│ 5.314 KiB      │    5442 │
│ invalid        │       0 │
└────────────────┴─────────┘
```

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

Introduced in: v22.7.0

Parse a sequence of numbers followed by something resembling a time unit.

The time delta string uses these time unit specifications:

- `years`, `year`, `yr`, `y`
- `months`, `month`, `mo`
- `weeks`, `week`, `w`
- `days`, `day`, `d`
- `hours`, `hour`, `hr`, `h`
- `minutes`, `minute`, `min`, `m`
- `seconds`, `second`, `sec`, `s`
- `milliseconds`, `millisecond`, `millisec`, `ms`
- `microseconds`, `microsecond`, `microsec`, `μs`, `µs`, `us`
- `nanoseconds`, `nanosecond`, `nanosec`, `ns`

Multiple time units can be combined with separators (space, `;`, `-`, `+`, `,`, `:`).

The length of years and months are approximations: year is 365 days, month is 30.5 days.

**Syntax**

```
parseTimeDelta(timestr)
```

**Arguments**

- `timestr` — A sequence of numbers followed by something resembling a time unit. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

The number of seconds. [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT parseTimeDelta('11s+22min')
```

```
┌─parseTimeDelta('11s+22min')─┐
│                        1331 │
└─────────────────────────────┘
```

**Complex time units**

```
SELECT parseTimeDelta('1yr2mo')
```

```
┌─parseTimeDelta('1yr2mo')─┐
│                 36806400 │
└──────────────────────────┘
```

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

Introduced in: v21.4.0

Computes the [partition ID](/docs/engines/table-engines/mergetree-family/custom-partitioning-key).

Note

This function is slow and should not be called for large numbers of rows.

**Syntax**

```
partitionId(column1[, column2, ...])
```

**Aliases**: `partitionID`

**Arguments**

- `column1, column2, ...` — Column for which to return the partition ID.

**Returned value**

Returns the partition ID that the row belongs to. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
DROP TABLE IF EXISTS tab;

CREATE TABLE tab
(
  i int,
  j int
)
ENGINE = MergeTree
PARTITION BY i
ORDER BY tuple();

INSERT INTO tab VALUES (1, 1), (1, 2), (1, 3), (2, 4), (2, 5), (2, 6);

SELECT i, j, partitionId(i), _partition_id FROM tab ORDER BY i, j;
```

```
┌─i─┬─j─┬─partitionId(i)─┬─_partition_id─┐
│ 1 │ 1 │ 1              │ 1             │
│ 1 │ 2 │ 1              │ 1             │
│ 1 │ 3 │ 1              │ 1             │
│ 2 │ 4 │ 2              │ 2             │
│ 2 │ 5 │ 2              │ 2             │
│ 2 │ 6 │ 2              │ 2             │
└───┴───┴────────────────┴───────────────┘
```

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

Introduced in: v21.9.0

Returns the ID of the current query.
Other parameters of a query can be extracted from field `query_id` in the [`system.query_log`](/docs/operations/system-tables/query_log) table.

In contrast to [`initialQueryID`](#initialQueryID) function, `queryID` can return different results on different shards.

**Syntax**

```
queryID()
```

**Aliases**: `query_id`

**Arguments**

- None.

**Returned value**

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

**Examples**

**Usage example**

```
CREATE TABLE tmp (str String) ENGINE = Log;
INSERT INTO tmp (*) VALUES ('a');
SELECT count(DISTINCT t) FROM (SELECT queryID() AS t FROM remote('127.0.0.{1..3}', currentDatabase(), 'tmp') GROUP BY queryID());
```

```
┌─count(DISTINCT t)─┐
│                 3 │
└───────────────────┘
```

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

Introduced in: v22.7.0