Array functions are a set of specialized functions provided in the OceanBase AI Database system for processing array data. These functions enable users to perform complex array queries and analyses.
The following table describes the array functions supported by OceanBase AI Database and their purposes:
Array functions
Array Function Types |
Description |
|---|---|
| Array constructor | A function for constructing a new array data type. |
| Array comparison functions | A function that performs a logical operation on the input array data and returns a boolean value. |
| Array output functions | Output the input array data and return the output array data. |
| Array functions | Performs basic operations on the input array data, such as adding elements, deleting elements, and searching for elements, and returns the array data after the operation. |
Overview of array functions
The following table lists all array functions supported by OceanBase AI Database:
Function type |
Function name |
Description |
|---|---|---|
| Array Constructor | array | Constructs an array data structure. |
| Array Constructor | rb_build | Converts an array of integers into a highly compressed bitmap data structure (RoaringBitmap). |
| operator | [] | Constructs an array data structure. |
| Array judgment function | array_contains | Determines whether a specific element is present in an array. |
| Array judgment function | array_contains_all | Determines whether the input array contains all elements of another array. |
| Array judgment function | array_overlaps | Determines whether two arrays have any common elements. |
| operator | ANY | Determines whether a specific element is present in the array, and is functionally the same as array_contains(). |
| Array Output Functions | array_to_string | Converts an array to a string. Specifically, it prints all the primitive elements in the array as a string using the specified separator and empty-element character. |
| Array manipulation functions | array_append | Adds a specified element to the end of the target array. |
| Array manipulation functions | array_distinct | Removes duplicates from the target array. |
| Array manipulation functions | array_remove | Removes specified elements from the target array. |
| Array manipulation functions | cardinality | Returns the number of elements in the target array. |
| Array manipulation functions | element_at | Retrieves the element at a specified index in the target array. |
| Array manipulation functions | string_to_array | Splits a string into a string array based on the specified delimiter. |
| Array manipulation functions | array_agg | Aggregates multiple rows of data on a specified column into a single array value and returns the result. |
| Array manipulation functions | unnest | This function is used to expand the elements in an array into multiple rows and return a relational table containing these elements. |
| Array manipulation functions | array_prepend | Adds an element to the beginning of an array and returns a new array. |
| Array manipulation functions | array_concat | Concatenates multiple arrays and returns a new array. |
| Array manipulation functions | array_compact | Removes consecutive duplicate elements from an array and returns a new array. |
| Array manipulation functions | array_sort | Sorts an array in ascending order and places NULL values at the end of the array. |
| Array manipulation functions | array_length | Returns the length of an array. For a nested array, it returns the length of the first-level array. |
| Array manipulation functions | array_range | Generates an arithmetic sequence array. |
| Array manipulation functions | array_sum | Calculates the sum of all elements in an array. |
| Array manipulation functions | array_diffrence | Calculates the differences between every two adjacent elements in an array and stores the results in a new array that is returned. |
| Array manipulation functions | array_min | Returns the minimum value in an array. NULL values are ignored. |
| Array manipulation functions | array_max | Returns the maximum value in an array. NULL values are ignored. |
| Array manipulation functions | array_avg | This function is used to return the average value of all elements in an array. NULL treated as a 0 Calculate. |
| Array manipulation functions | array_position | Retrieves the index of a specified element in an array. |
| Array manipulation functions | array_slice | Extracts a portion of elements from an array starting at a specified index and returns the extracted elements as a new array. |
| Array manipulation functions | reverse | Reverses the order of elements in an array. For nested arrays, it reverses the order of the first-level elements. |
| Array manipulation functions | array_map | It is used to apply a Lambda function to each element of the input arrays and concatenate all the transformed elements into a single output array. |
| Array manipulation functions | array_filter | Determines whether to filter elements in the array based on the return value of the lambda function. |
| Array manipulation functions | array_sortby | Sorts an array based on the given lambda function. |
| Array operation function | array_first | Returns the first element in an array for which the given lambda function returns a value other than 0. |