Hologres is compatible with PostgreSQL and allows you to use the standard PostgreSQL syntax for data development.
The following table describes the array functions that are supported by Hologres. The functions supported by Hologres are only a subset of the PostgreSQL functions. For more information about how to use these functions, see Array Functions and Operators in the PostgreSQL documentation.
Limits
array_max
, array_min
, array_contains
, array_except
, array_distinct
, and array_union
functions do not support constant queries, such as select array_max(ARRAY[-2, NULL, -3, -12, -7]);
.
Operators
Operator | Return type | Description | Example | Result |
@> | BOOLEAN | Checks whether Array A contains Array B. | SELECT ARRAY[1,2,3] @> ARRAY[1,2]; | t |
<@ | BOOLEAN | Checks whether Array A is contained by Array B. | SELECT ARRAY[1,2,3] <@ ARRAY[1,2]; | f |
&& | BOOLEAN | Checks whether two arrays have same elements. Note In Hologres V1.3.37 and later, data of the ARRAY type can be used as input parameters. | SELECT ARRAY[1,2,3] && ARRAY[1,2]; | t |
Functions
Function | Return type | Description | Example | Result |
array_to_string(anyarray,text[,text]) | TEXT | Concatenates array elements with a specified delimiter and an optional empty string. | array_to_string(ARRAY[1, 2, 3], ',') | 1,2,3 |
array_agg(anyelement) | ARRAY | Concatenates the values of an expression into an array.
|
|
|
array_agg (expression[ order_by_clause ] ) [ FILTER ( WHERE filter_clause ) ] | ARRAY | Concatenates the values of an expression into an array. Hologres V1.3 and later support FILTER statements. |
|
|
array_append(anyarray, anyelement) | ARRAY | Appends an element to the end of an array. | array_append(ARRAY[1,2], 3) | {1,2,3} |
array_cat(anyarray,anyarray) | ARRAY | Concatenates two arrays. | array_cat(ARRAY[1,2,3], ARRAY[4,5]) | {1,2,3,4,5} |
array_ndims(anyarray) | ARRAY | Returns the number of dimensions of an array. | array_ndims(ARRAY[[1,2,3], [4,5,6]]) | 2 |
array_dims(anyarray) | ARRAY | Returns the dimensions of an array in the text format. | array_dims(ARRAY[[1,2,3], [4,5,6]]) | [1:2][1:3] |
array_length(anyarray, int) | ARRAY | Returns the length of the dimension of the requested array. | array_length(ARRAY[1,2,3], 1) | 3 |
array_lower(anyarray, int) | ARRAY | Returns the lower bound of the dimension of the requested array. | array_lower('[0:2]={1,2,3}'::int[], 1) | 0 |
array_positions(anyarray, anyelement) | ARRAY | Returns an array of the location of the second argument in the first argument. The array returned must be one-dimensional. | array_positions(ARRAY['A','A','B','A'], 'A') | {1,2,4} |
array_prepend(anyelement, anyarray) | ARRAY | Prepends an element to the start of an array. | array_prepend(1, ARRAY[2,3]) | {1,2,3} |
array_remove(anyarray, anyelement) | ARRAY | Removes all elements that are equal to the specified value from an array. | array_remove(ARRAY[1,2,3,2], 2) | {1,3} |
array_sort(anyarray) | ARRAY | Sorts the elements in an array.
| array_sort(ARRAY[1,3,2,1]) | {1,1,2,3} |
array_upper(anyarray, int) | INT | Returns the upper bound of the dimension of the requested array. | array_upper(ARRAY[1,8,3,7], 1) | 4 |
unnest(anyarray) | TEXT | Returns array elements that are displayed in multiple rows. | unnest(ARRAY[1,2]) | 1 2 (2 rows) |
array_max(array) | INT | Returns the maximum value among all data of an array. NULL values are not used for calculation. Note This function is supported by Hologres V1.3.19 and later. |
|
|
array_min(array) | INT | Returns the minimum value among all data of an array. Note This function is supported by Hologres V1.3.19 and later. |
|
|
array_contains(array, target_value) | BOOLEAN | If an array contains the value of the Note This function is supported by Hologres V1.3.19 and later. |
|
|
array_except(array1, array2) | ARRAY | Returns an array whose elements belong to Note This function is supported by Hologres V1.3.19 and later. |
|
|
array_distinct(array) | ARRAY | Removes duplicate values from an Note This function is supported by Hologres V1.3.19 and later. |
|
|
array_union(array1, array2) | ARRAY | Returns an array whose elements are the values in the union of Note This function is supported by Hologres V1.3.19 and later. |
|
|