Documentation / SQL / Functions
Array Functions
All LIST functions work with the ARRAY data type. Additionally, several ARRAY-native functions are also supported.
| Description | Create 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] |
| Description | Compute 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 | Compute 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.9925833 |
| Description | Compute 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 | Compute 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 |
| Description | Alias for array_inner_product(array1, array2). |
| Example | array_dot_product(l1, l2) |
| Result | 20.0 |
© 2025 DuckDB Foundation, Amsterdam NL