Subscript operator: []
The[] operator is used to access an element of an array and is indexed starting from one:
Concatenation operator: ||
The|| operator is used to concatenate an array with an array or an element of the same type:
Array functions
all_match
true if all the elements
match the predicate (a special case is when the array is empty); false if one or more elements don’t
match; NULL if the predicate function returns NULL for one or more elements and true for all
other elements.
any_match
true if one or more
elements match the predicate; false if none of the elements matches (a special case is when the
array is empty); NULL if the predicate function returns NULL for one or more elements and false
for all other elements.
array_distinct
x.
array_intersect
x and y, without duplicates.
array_union
x and y, without duplicates.
array_except
x but not in y, without duplicates.
array_histogram
x and the values are the number of times that each element appears in
x. Null values are ignored.
array_join
array_max
array_min
array_position
element in array x (or 0 if not found).
array_remove
element from array x.
array_sort
x. The elements of x must be orderable.
Null elements will be placed at the end of the returned array.
array based on the given comparator function.
The comparator will take two nullable arguments representing two nullable
elements of the array. It returns -1, 0, or 1 as the first nullable
element is less than, equal to, or greater than the second nullable element.
If the comparator function returns other values (including NULL), the
query will fail and raise an error.
arrays_overlap
x and y have any non-null elements in common.
Returns null if there are no non-null elements in common but either array contains null.
cardinality
x.
concat
array1, array2, ..., arrayN.
This function provides the same functionality as the SQL-standard concatenation operator (||).
combinations
combinations returns n-element subsets.
n must be not be greater than 5,
and the total size of sub-groups generated must be smaller than 100,000.
contains
x contains the element.
contains_sequence
x contains all of array seq as a subsequence (all values in the same consecutive order).
element_at
array at given index.
If index > 0, this function provides the same functionality as the SQL-standard subscript operator ([]),
except that the function returns NULL when accessing an index larger than array length, whereas
the subscript operator would fail in such a case.
If index < 0, element_at accesses elements from the last to the first.
filter
array for which function returns true:
flatten
array(array(T)) to an array(T) by concatenating the contained arrays.
ngrams
n-grams (sub-sequences of adjacent n elements) for the array.
The order of the n-grams in the result is unspecified.
none_match
true if none of the elements
matches the predicate (a special case is when the array is empty); false if one or more elements match;
NULL if the predicate function returns NULL for one or more elements and false for all other elements.
reduce
array. inputFunction will
be invoked for each element in array in order. In addition to taking
the element, inputFunction takes the current state, initially
initialState, and returns the new state. outputFunction will be
invoked to turn the final state into the result value. It may be the
identity function (i -> i).
repeat
element for count times.
reverse
x.
sequence
start to stop, incrementing
by 1 if start is less than or equal to stop, otherwise -1.
start to stop, incrementing by step.
start date to stop date, incrementing
by 1 day if start date is less than or equal to stop date, otherwise -1 day.
start to stop, incrementing by step.
The type of step can be either INTERVAL DAY TO SECOND or INTERVAL YEAR TO MONTH.
start to stop, incrementing by step.
The type of step can be either INTERVAL DAY TO SECOND or INTERVAL YEAR TO MONTH.
shuffle
x.
slice
x starting from index start (or starting from the end
if start is negative) with a length of length.
trim_array
n elements from the end of array:
transform
function to each element of array:
zip
NULL.
zip_with
function.
If one array is shorter, nulls are appended at the end to match the length of the
longer array, before applying function.