Array Functions
Array Functions
Syntax
Function | Description | Example | Result |
---|---|---|---|
get(array1, index) | Get item from an array by index | get([1,2], 2) | 2 |
length(array1) | Output the length of an array | length([1,2]) | 2 |
array_concat(array1, array2) | Concat two arrays | array_concat([1,2], [3, 4] | [1,2,3,4] |
array_contains(array, item) | Check if array has some item | array_contains([1,2], 1) | 1 |
array_indexof(array, item) | Returns the index of the element if the list contains the element. list_contains([1, 2, NULL], | array_indexof([1,2,9], 9); | 3 |
array_slice(array, start, end) | Extract a sublist using slice conventions | array_slice([1,21,32,4], 2, 3) | [21, 32] |
array_sort(array) | Sort an array | array_sort([1,4,3,2]) | [1,2,3,4] |
array_<aggr>(array) | Aggregate the array using aggr name(currently support: sum, count, avg, min, max, any) | array_sum([1,2,3,4] | 10 |
array_unique(array) | Counts the unique elements of an array | array_unique([1,2,3,3,4]) | 4 |
array_distinct(array) | Removes all duplicates and NULLs from an array. Does not preserve the original order. | array_distinct([1,2,2,4]) | [1,2,4] |
array_prepend(item, array) | Prepend item into an array | array_prepend(1, [3, 4]) | [1,3,4] |
array_append(array, item) | Append item into an array | array_append([3, 4], 5) | [3,4,5] |
array_remove_first(array) | Remove the first element from an array | array_remove_first([1,2,3]) | [2,3] |
array_remove_last(array) | Remove the last element from an array | array_remove_last([1,2,3]) | [1,2] |