- Categories:
VECTOR_TRUNCATE¶
Truncates a VECTOR to a smaller dimension.
This function can also be called through the alias VECTOR_TRUNC.
- See also:
Syntax¶
VECTOR_TRUNCATE( <vector>, <dimension> )
Arguments¶
vectorA single VECTOR value to truncate.
dimensionThe number of elements that should be in the returned vector.
Returns¶
Returns a VECTOR value with the same values and types for the first dimension entries, with the remainder discarded.
Usage notes¶
Returns NULL when any input is NULL.
Using a
dimensionlarger than the number of dimensions in thevectorcauses an error.Truncated vectors are not normalized.
Examples¶
This example demonstrates truncating a 3-dimensional vector into a 2-dimensional vector:
SELECT VECTOR_TRUNCATE([1, 2, 3]::VECTOR(INT, 3), 2);
[1,2]
This example demonstrates truncating a vector produced by EMBED_TEXT_768 for the text “Analytical databases are typically column-oriented rather than row-oriented” with the snowflake-arctic-embed-m-v1.5 model from 768 elements to 256 elements:
SELECT VECTOR_TRUNCATE(
SNOWFLAKE.CORTEX.EMBED_TEXT_768(
'snowflake-arctic-embed-m-v1.5',
'Analytical databases are typically column-oriented rather than row-oriented'
),
256)
;