Skip to main content

Overview of array functions

Array functions are a set of specialized functions provided by the seekdb system for processing array data. These functions allow users to perform complex array queries and analyses.

Here is an overview of some array functions in seekdb and their purposes:

Types of array functions

Type of array functionDescription
Array constructor functionsFunctions for constructing new array data types.
Array decision functionsFunctions for performing logical judgments on input array data and returning boolean values.
Array output functionsFunctions for outputting input array data and returning the output array data.
Array manipulation functionsFunctions for performing basic operations on input array data, such as adding, deleting, and searching for elements, and returning the manipulated array data.

Overview of all array functions

The following table lists all array functions supported by seekdb:

Function typeFunction nameDescription
Array constructor functionarrayConstructs an array data type.
Array constructor functionrb_buildConverts an array data type with an integer as its base type into an efficient compressed bitmap data type (RoaringBitmap).
Operator[]Constructs an array data type.
Array decision functionarray_containsChecks whether an element exists in an array.
Array decision functionarray_contains_allChecks whether an input array contains all elements of another array.
Array decision functionarray_overlapsChecks whether two arrays have an intersection.
OperatorANYChecks whether an element exists in an array, with the same functionality as the array_contains() function.
Array output functionarray_to_stringConverts an array into a string. Specifically, it prints all base elements in the array into a string based on the specified separator and empty element symbol.
Array manipulation functionarray_appendAdds a specified element to a target array.
Array manipulation functionarray_distinctRemoves duplicate elements from a target array.
Array manipulation functionarray_removeRemoves a specified element from a target array.
Array manipulation functioncardinalityReturns the number of base elements in a target array.
Array manipulation functionelement_atReturns an element at a specified position in a target array based on the index.
Array manipulation functionstring_to_arraySplits a string into a string array based on a specified separator.
Array manipulation functionarray_aggAggregates multiple rows of data on a specified column into one array value and returns the result.
Array manipulation functionunnestExpands elements in an array into multiple rows and returns a relation table containing these elements.
Array manipulation functionarray_prependAdds an element to the beginning of an array and returns a new array.
Array manipulation functionarray_concatMerges multiple arrays into one and returns a new array.
Array manipulation functionarray_compactRemoves consecutive duplicate elements from an array and returns a new array.
Array manipulation functionarray_sortSorts an array in ascending order and places NULL values at the end of the array during sorting.
Array manipulation functionarray_lengthReturns the length of an array. If the array is nested, it returns the length of the top-level array.
Array manipulation functionarray_rangeGenerates an evenly spaced array.
Array manipulation functionarray_sumCalculates the sum of all elements in an array.
Array manipulation functionarray_differenceCalculates the difference between two adjacent elements in an array and stores the result in a new array.
Array manipulation functionarray_minReturns the minimum value in an array, ignoring NULL values.
Array manipulation functionarray_maxReturns the maximum value in an array, ignoring NULL values.
Array manipulation functionarray_avgReturns the average value of all elements in an array, treating NULL values as 0.
Array manipulation functionarray_positionFinds the position of a specified element in an array.
Array manipulation functionarray_sliceExtracts a portion of elements from an array starting at a specified position and returns a new array containing the extracted elements.
Array manipulation functionreverseReverses the order of elements in an array. If the array is nested, it reverses the order of elements at the top level.
Array manipulation functionarray_mapConverts each element in an input array based on a Lambda function and returns a new array containing all the converted elements.
Array manipulation functionarray_filterFilters elements in an array based on the return value of a Lambda function.
Array manipulation functionarray_sortbySorts an array based on a given Lambda function.
Array manipulation functionarray_firstReturns the first element in an array that makes the return value of a given Lambda function not equal to 0.