# NumericIndexedVector (/docs/reference/sql/functions/numericindexedvector)



This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See [SQL interface scope](/docs/reference/clickhouse-compatibility#service-interfaces).

numericIndexedVectorAllValueSum [#numericindexedvectorallvaluesum]

Returns the sum of all values in the numericIndexedVector.

**Syntax**

```sql
numericIndexedVectorAllValueSum(v)
```

**Arguments**

* `v` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns the sum. [`Float64`](/reference/data-types/float)

**Examples**

**Usage example**

```sql title=Query
SELECT numericIndexedVectorAllValueSum(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res;
```

```text title=Response
┌─res─┐
│  60 │
└─────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorBuild [#numericindexedvectorbuild]

Creates a NumericIndexedVector from a map. The map's keys represent the vector's index and map's value represents the vector's value.

**Syntax**

```sql
numericIndexedVectorBuild(map)
```

**Arguments**

* `map` — A mapping from index to value. [`Map`](/reference/data-types/map)

**Returned value**

Returns a NumericIndexedVector object. [`AggregateFunction`](/reference/data-types/aggregatefunction)

**Examples**

**Usage example**

```sql title=Query
SELECT numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30])) AS res, toTypeName(res);
```

```text title=Response
┌─res─┬─toTypeName(res)────────────────────────────────────────────┐
│     │ AggregateFunction(groupNumericIndexedVector, UInt8, UInt8) │
└─────┴────────────────────────────────────────────────────────────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorCardinality [#numericindexedvectorcardinality]

Returns the cardinality (number of unique indexes) of the numericIndexedVector.

**Syntax**

```sql
numericIndexedVectorCardinality(v)
```

**Arguments**

* `v` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns the number of unique indexes. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query
SELECT numericIndexedVectorCardinality(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res;
```

```text title=Response
┌─res─┐
│  3  │
└─────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorGetValue [#numericindexedvectorgetvalue]

Retrieves the value corresponding to a specified index from a numericIndexedVector.

**Syntax**

```sql
numericIndexedVectorGetValue(v, i)
```

**Arguments**

* `v` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `i` — The index for which the value is to be retrieved. [`(U)Int*`](/reference/data-types/int-uint)

**Returned value**

A numeric value with the same type as the value type of NumericIndexedVector. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float)

**Examples**

**Usage example**

```sql title=Query
SELECT numericIndexedVectorGetValue(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30])), 3) AS res;
```

```text title=Response
┌─res─┐
│  30 │
└─────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseAdd [#numericindexedvectorpointwiseadd]

Performs pointwise addition between a numericIndexedVector and either another numericIndexedVector or a numeric constant.

**Syntax**

```sql
numericIndexedVectorPointwiseAdd(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

**Usage example**

```sql title=Query
WITH
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseAdd(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseAdd(vec1, 2)) AS res2;
```

```text title=Response
┌─res1──────────────────┬─res2─────────────┐
│ {1:10,2:30,3:50,4:30} │ {1:12,2:22,3:32} │
└───────────────────────┴──────────────────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseDivide [#numericindexedvectorpointwisedivide]

Performs pointwise division between a numericIndexedVector and either another numericIndexedVector or a numeric constant.

**Syntax**

```sql
numericIndexedVectorPointwiseDivide(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

**Usage example**

```sql title=Query
with
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) as vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [10, 20, 30]))) as vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseDivide(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseDivide(vec1, 2)) AS res2;
```

```text title=Response
┌─res1────────┬─res2────────────┐
│ {2:2,3:1.5} │ {1:5,2:10,3:15} │
└─────────────┴─────────────────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseEqual [#numericindexedvectorpointwiseequal]

Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant.
The result is a numericIndexedVector containing the indices where the values are equal, with all corresponding values set to 1.

**Syntax**

```sql
numericIndexedVectorPointwiseEqual(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

***

```sql title=Query
with
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) as vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 20, 30]))) as vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseEqual(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseEqual(vec1, 20)) AS res2;
```

```text title=Response
┌─res1──┬─res2──┐
│ {2:1} │ {2:1} │
└───────┴───────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseGreater [#numericindexedvectorpointwisegreater]

Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant.
The result is a numericIndexedVector containing the indices where the first vector's value is greater than the second vector's value, with all corresponding values set to 1.

**Syntax**

```sql
numericIndexedVectorPointwiseGreater(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

**Usage example**

```sql title=Query
with
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 50]))) as vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 40, 30]))) as vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseGreater(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseGreater(vec1, 20)) AS res2;
```

```text title=Response
┌─res1──────┬─res2──┐
│ {1:1,3:1} │ {3:1} │
└───────────┴───────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseGreaterEqual [#numericindexedvectorpointwisegreaterequal]

Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant.
The result is a numericIndexedVector containing the indices where the first vector's value is greater than or equal to the second vector's value, with all corresponding values set to 1.

**Syntax**

```sql
numericIndexedVectorPointwiseGreaterEqual(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

**Usage example**

```sql title=Query
with
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 50]))) as vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 40, 30]))) as vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseGreaterEqual(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseGreaterEqual(vec1, 20)) AS res2;
```

```text title=Response
┌─res1──────────┬─res2──────┐
│ {1:1,2:1,3:1} │ {2:1,3:1} │
└───────────────┴───────────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseLess [#numericindexedvectorpointwiseless]

Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant.
The result is a numericIndexedVector containing the indices where the first vector's value is less than the second vector's value, with all corresponding values set to 1.

**Syntax**

```sql
numericIndexedVectorPointwiseLess(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

**Usage example**

```sql title=Query
with
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) as vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 40, 30]))) as vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseLess(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseLess(vec1, 20)) AS res2;
```

```text title=Response
┌─res1──────┬─res2──┐
│ {3:1,4:1} │ {1:1} │
└───────────┴───────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseLessEqual [#numericindexedvectorpointwiselessequal]

Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant.
The result is a numericIndexedVector containing the indices where the first vector's value is less than or equal to the second vector's value, with all corresponding values set to 1.

**Syntax**

```sql
numericIndexedVectorPointwiseLessEqual(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

**Usage example**

```sql title=Query
with
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) as vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 40, 30]))) as vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseLessEqual(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseLessEqual(vec1, 20)) AS res2;
```

```text title=Response
┌─res1──────────┬─res2──────┐
│ {2:1,3:1,4:1} │ {1:1,2:1} │
└───────────────┴───────────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseMultiply [#numericindexedvectorpointwisemultiply]

Performs pointwise multiplication between a numericIndexedVector and either another numericIndexedVector or a numeric constant.

**Syntax**

```sql
numericIndexedVectorPointwiseMultiply(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

***

```sql title=Query
with
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toInt32(x), [10, 20, 30]))) as vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toInt32(x), [10, 20, 30]))) as vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseMultiply(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseMultiply(vec1, 2)) AS res2;
```

```text title=Response
┌─res1──────────┬─res2─────────────┐
│ {2:200,3:600} │ {1:20,2:40,3:60} │
└───────────────┴──────────────────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseNotEqual [#numericindexedvectorpointwisenotequal]

Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant.
The result is a numericIndexedVector containing the indices where the values are not equal, with all corresponding values set to 1.

**Syntax**

```sql
numericIndexedVectorPointwiseNotEqual(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

**Usage example**

```sql title=Query
with
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) as vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 20, 30]))) as vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseNotEqual(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseNotEqual(vec1, 20)) AS res2;
```

```text title=Response
┌─res1──────────┬─res2──────┐
│ {1:1,3:1,4:1} │ {1:1,3:1} │
└───────────────┴───────────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorPointwiseSubtract [#numericindexedvectorpointwisesubtract]

Performs pointwise subtraction between a numericIndexedVector and either another numericIndexedVector or a numeric constant.

**Syntax**

```sql
numericIndexedVectorPointwiseSubtract(v1, v2)
```

**Arguments**

* `v1` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)
* `v2` — A numeric constant or numericIndexedVector object. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a new numericIndexedVector object. [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Examples**

**Usage example**

```sql title=Query
WITH
    numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec1,
    numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec2
SELECT
    numericIndexedVectorToMap(numericIndexedVectorPointwiseSubtract(vec1, vec2)) AS res1,
    numericIndexedVectorToMap(numericIndexedVectorPointwiseSubtract(vec1, 2)) AS res2;
```

```text title=Response
┌─res1───────────────────┬─res2────────────┐
│ {1:10,2:10,3:10,4:-30} │ {1:8,2:18,3:28} │
└────────────────────────┴─────────────────┘
```

*Introduced in version 25.7.0.*

numericIndexedVectorShortDebugString [#numericindexedvectorshortdebugstring]

Returns internal information of the numericIndexedVector in JSON format.
This function is primarily used for debugging purposes.

**Syntax**

```sql
numericIndexedVectorShortDebugString(v)
```

**Arguments**

* `v` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a JSON string containing debug information. [`String`](/reference/data-types/string)

**Examples**

**Usage example**

```sql title=Query
SELECT numericIndexedVectorShortDebugString(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res\G;
```

```text title=Response
Row 1:
──────
res: {"vector_type":"BSI","index_type":"char8_t","value_type":"char8_t","integer_bit_num":8,"fraction_bit_num":0,"zero_indexes_info":{"cardinality":"0"},"non_zero_indexes_info":{"total_cardinality":"3","all_value_sum":60,"number_of_bitmaps":"8","bitmap_info":{"cardinality":{"0":"0","1":"2","2":"2","3":"2","4":"2","5":"0","6":"0","7":"0"}}}}
```

*Introduced in version 25.7.0.*

numericIndexedVectorToMap [#numericindexedvectortomap]

Converts a numericIndexedVector to a map.

**Syntax**

```sql
numericIndexedVectorToMap(v)
```

**Arguments**

* `v` —  [`numericIndexedVector`](/reference/functions/regular-functions/numeric-indexed-vector-functions#create-numeric-indexed-vector-object)

**Returned value**

Returns a map with index-value pairs. [`Map`](/reference/data-types/map)

**Examples**

**Usage example**

```sql title=Query
SELECT numericIndexedVectorToMap(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res;
```

```text title=Response
┌─res──────────────┐
│ {1:10,2:20,3:30} │
└──────────────────┘
```

*Introduced in version 25.7.0.*
