Skip to main content

Array Functions

Array Functions

Syntax

FunctionDescriptionExampleResult
get(array1, index)Get item from an array by indexget([1,2], 2)2
length(array1)Output the length of an arraylength([1,2])2
array_concat(array1, array2)Concat two arraysarray_concat([1,2], [3, 4][1,2,3,4]
array_contains(array, item)Check if array has some itemarray_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 conventionsarray_slice([1,21,32,4], 2, 3)[21, 32]
array_sort(array)Sort an arrayarray_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 arrayarray_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 arrayarray_prepend(1, [3, 4])[1,3,4]
array_append(array, item)Append item into an arrayarray_append([3, 4], 5)[3,4,5]
array_remove_first(array)Remove the first element from an arrayarray_remove_first([1,2,3])[2,3]
array_remove_last(array)Remove the last element from an arrayarray_remove_last([1,2,3])[1,2]