Documentation / SQL / Functions
Array Functions
All LIST functions work with the ARRAY data type. Additionally, several ARRAY-native functions are also supported.
| Description | Computes the cosine distance between two arrays of the same size. The array elements can not be NULL. The arrays can have any size as long as the size is the same for both arguments. |
| Example | array_cosine_distance(array_value(1.0::FLOAT, 2.0::FLOAT, 3.0::FLOAT), array_value(2.0::FLOAT, 3.0::FLOAT, 4.0::FLOAT)) |
| Result | 0.007416606 |
| Description | Computes the cosine similarity between two arrays of the same size. The array elements can not be NULL. The arrays can have any size as long as the size is the same for both arguments. |
| Example | array_cosine_similarity(array_value(1.0::FLOAT, 2.0::FLOAT, 3.0::FLOAT), array_value(2.0::FLOAT, 3.0::FLOAT, 4.0::FLOAT)) |
| Result | 0.9925834 |
| Description | Computes the cross product of two arrays of size 3. The array elements can not be NULL. |
| Example | array_cross_product(array_value(1.0::FLOAT, 2.0::FLOAT, 3.0::FLOAT), array_value(2.0::FLOAT, 3.0::FLOAT, 4.0::FLOAT)) |
| Result | [-1.0, 2.0, -1.0] |
| Description | Computes the distance between two arrays of the same size. The array elements can not be NULL. The arrays can have any size as long as the size is the same for both arguments. |
| Example | array_distance(array_value(1.0::FLOAT, 2.0::FLOAT, 3.0::FLOAT), array_value(2.0::FLOAT, 3.0::FLOAT, 4.0::FLOAT)) |
| Result | 1.7320508 |
| Description | Computes the inner product between two arrays of the same size. The array elements can not be NULL. The arrays can have any size as long as the size is the same for both arguments. |
| Example | array_inner_product(array_value(1.0::FLOAT, 2.0::FLOAT, 3.0::FLOAT), array_value(2.0::FLOAT, 3.0::FLOAT, 4.0::FLOAT)) |
| Result | 20.0 |
| Alias | array_dot_product |
| Description | Computes the negative inner product between two arrays of the same size. The array elements can not be NULL. The arrays can have any size as long as the size is the same for both arguments. |
| Example | array_negative_inner_product(array_value(1.0::FLOAT, 2.0::FLOAT, 3.0::FLOAT), array_value(2.0::FLOAT, 3.0::FLOAT, 4.0::FLOAT)) |
| Result | -20.0 |
| Alias | array_negative_dot_product |
| Description | Creates an ARRAY containing the argument values. |
| Example | array_value(1.0::FLOAT, 2.0::FLOAT, 3.0::FLOAT) |
| Result | [1.0, 2.0, 3.0] |
© 2025 DuckDB Foundation, Amsterdam NL