ReferenceSQL ReferenceFunctions

NumericIndexedVector

NumericIndexedVector functions reference.

numericIndexedVectorAllValueSum

Returns the sum of all values in the numericIndexedVector.

Syntax

numericIndexedVectorAllValueSum(v)

Arguments

Returned value

Returns the sum. Float64

Examples

Usage example

SELECT numericIndexedVectorAllValueSum(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res;
┌─res─┐
│  60 │
└─────┘

Introduced in version 25.7.

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

numericIndexedVectorBuild(map)

Arguments

  • map — A mapping from index to value. Map

Returned value

Returns a NumericIndexedVector object. AggregateFunction

Examples

Usage example

SELECT numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30])) AS res, toTypeName(res);
┌─res─┬─toTypeName(res)────────────────────────────────────────────┐
│     │ AggregateFunction(groupNumericIndexedVector, UInt8, UInt8) │
└─────┴────────────────────────────────────────────────────────────┘

Introduced in version 25.7.

numericIndexedVectorCardinality

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

Syntax

numericIndexedVectorCardinality(v)

Arguments

Returned value

Returns the number of unique indexes. UInt64

Examples

Usage example

SELECT numericIndexedVectorCardinality(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res;
┌─res─┐
│  3  │
└─────┘

Introduced in version 25.7.

numericIndexedVectorGetValue

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

Syntax

numericIndexedVectorGetValue(v, i)

Arguments

Returned value

A numeric value with the same type as the value type of NumericIndexedVector. (U)Int* or Float*

Examples

Usage example

SELECT numericIndexedVectorGetValue(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30])), 3) AS res;
┌─res─┐
│  30 │
└─────┘

Introduced in version 25.7.

numericIndexedVectorPointwiseAdd

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

Syntax

numericIndexedVectorPointwiseAdd(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples

Usage example

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;
┌─res1──────────────────┬─res2─────────────┐
│ {1:10,2:30,3:50,4:30} │ {1:12,2:22,3:32} │
└───────────────────────┴──────────────────┘

Introduced in version 25.7.

numericIndexedVectorPointwiseDivide

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

Syntax

numericIndexedVectorPointwiseDivide(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples

Usage example

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;
┌─res1────────┬─res2────────────┐
│ {2:2,3:1.5} │ {1:5,2:10,3:15} │
└─────────────┴─────────────────┘

Introduced in version 25.7.

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

numericIndexedVectorPointwiseEqual(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples


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;
┌─res1──┬─res2──┐
│ {2:1} │ {2:1} │
└───────┴───────┘

Introduced in version 25.7.

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

numericIndexedVectorPointwiseGreater(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples

Usage example

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;
┌─res1──────┬─res2──┐
│ {1:1,3:1} │ {3:1} │
└───────────┴───────┘

Introduced in version 25.7.

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

numericIndexedVectorPointwiseGreaterEqual(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples

Usage example

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;
┌─res1──────────┬─res2──────┐
│ {1:1,2:1,3:1} │ {2:1,3:1} │
└───────────────┴───────────┘

Introduced in version 25.7.

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

numericIndexedVectorPointwiseLess(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples

Usage example

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;
┌─res1──────┬─res2──┐
│ {3:1,4:1} │ {1:1} │
└───────────┴───────┘

Introduced in version 25.7.

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

numericIndexedVectorPointwiseLessEqual(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples

Usage example

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;
┌─res1──────────┬─res2──────┐
│ {2:1,3:1,4:1} │ {1:1,2:1} │
└───────────────┴───────────┘

Introduced in version 25.7.

numericIndexedVectorPointwiseMultiply

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

Syntax

numericIndexedVectorPointwiseMultiply(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples


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;
┌─res1──────────┬─res2─────────────┐
│ {2:200,3:600} │ {1:20,2:40,3:60} │
└───────────────┴──────────────────┘

Introduced in version 25.7.

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

numericIndexedVectorPointwiseNotEqual(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples

Usage example

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;
┌─res1──────────┬─res2──────┐
│ {1:1,3:1,4:1} │ {1:1,3:1} │
└───────────────┴───────────┘

Introduced in version 25.7.

numericIndexedVectorPointwiseSubtract

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

Syntax

numericIndexedVectorPointwiseSubtract(v1, v2)

Arguments

Returned value

Returns a new numericIndexedVector object. numericIndexedVector

Examples

Usage example

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;
┌─res1───────────────────┬─res2────────────┐
│ {1:10,2:10,3:10,4:-30} │ {1:8,2:18,3:28} │
└────────────────────────┴─────────────────┘

Introduced in version 25.7.

numericIndexedVectorShortDebugString

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

Syntax

numericIndexedVectorShortDebugString(v)

Arguments

Returned value

Returns a JSON string containing debug information. String

Examples

Usage example

SELECT numericIndexedVectorShortDebugString(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res\G;
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.

numericIndexedVectorToMap

Converts a numericIndexedVector to a map.

Syntax

numericIndexedVectorToMap(v)

Arguments

Returned value

Returns a map with index-value pairs. Map

Examples

Usage example

SELECT numericIndexedVectorToMap(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res;
┌─res──────────────┐
│ {1:10,2:20,3:30} │
└──────────────────┘

Introduced in version 25.7.