Array Functions
Operate on array values using the array functions supported by the Query service.
Function | Return Type | Input Arguments | Description |
---|---|---|---|
all_match(arr[T], function(T, boolean)) | Boolean |
| Returns whether all elements of an array match the given predicate function. If all the elements match the predicate function, this function returns TRUE. If one or more elements don’t match, this function returns FALSE. |
any_match(arr[T], function(T, boolean)) | Boolean |
| Returns whether any elements of an array match the given predicate function. If one or more elements match the predicate function, this function returns TRUE. If no elements match the predicate, this function returns FALSE. |
array_distinct(arr[]) | Array |
| Returns the distinct values in the input array. |
array_except(arr1[], arr2[]) | Array |
| Returns an array of elements in arr1[] but not in arr2[]. This function eliminates any items that are duplicated in the two arrays. |
array_intersect(arr1[], arr2[]) | Array |
| Returns an array of elements common to arr1[] and arr2[]. This function finds items that are duplicated in the two arrays. |
array_join(arr[], delimiter, null_replacement) | Varchar |
| Concatenates the elements of the array and the delimiter specified in the input arguments. Null values in the array are replaced with an optional null_replacement character. |
array_max(arr[]) | Data type of the elements in the input array |
| Returns the maximum value in arr[]. |
array_min(arr[]) | Data type of the elements in the input array |
| Returns the minimum value in arr[]. |
array_position(arr[], element) | Bigint |
| Returns the position of the first occurrence of element in arr[]. If the element isn’t found, it returns zero. |
array_remove(arr[], element) | Array |
| Removes the specified element from the array. |
array_sort(arr[]) | Array |
| Returns an array with sorted elements. Nulls are placed at the end. |
array_union(arr1[], arr2[]) | Array |
| Returns the union of arr1[] and arr2[] without duplicates. |
arrays_overlap(arr1[], arr2[]) | Boolean |
| Returns TRUE if arrays arr1[] and arr2[] have any non-null elements in common, or FALSE otherwise. |
cardinality(arr[]) | Bigint |
| Returns the size of the input array. |
combinations(arr[]) | An array of arrays |
| Returns all the possible n-element subgroups of the input array. |
concat(arr1[], arr2[], ...) | Array |
| Returns a concatenated array of the input arrays. |
contains(arr[], element) | Boolean |
| Returns TRUE if the array arr[] contains the element, or FALSE otherwise. |
element_at(arr[], index) | Data type of the array elements |
| Returns the element from the array arr[] at the index position. |
filter(arr[T], function(Tboolean)) | Array |
| Returns an array of those elements from array arr[] for which function() returns TRUE. For example:
|
flatten(arr[]) | Array |
| Returns a flattened array (array[T]) by concatenating the contained arrays. |
ngrams(arr[]) | Array |
| Returns n-grams for the array arr[]. |
repeat(element, count) | Array |
| Repeats element for count times. |
reverse(arr[]) | Array |
| Returns an array that reverses the order of the elements in the input array. |
sequence(start, stop) | Integer |
| Generates a sequence of integers from start to stop. If start is less than or equal to stop, it increments by positive 1. Otherwise, it decrements by negative 1. |
shuffle(arr[]) | Array |
| Returns a random permutation of the input array. |
slice(arr[], index, length) | Array |
| Returns an array using elements taken from the input array starting from index index with a length of length. |
transform(arr[T], function(T, X)) | Array |
| Returns an array that is the result of applying function() to each element of the input array. For example:
|
zip(arr1[], arr2[], ...) | Array |
| Returns an array formed by merging the given arrays element-wise into a single array. If the arguments have an uneven length, missing values are replaced with null. |
zip_with(arr1[], arr2[], function(x, y)) | Array |
| Merges the two input arrays element-wise into a single array by using function(). If one array is shorter than the other, nulls are appended at the end to match the length of the longer array before applying function(). |