Array functions
array_sort()
Signature:
array_sort(array: ARRAY<T>) -> ARRAY<T>Returns a array with the sorted order of the array. T must be an orderable type. Null elements are placed at the end of the returned array. May throw an error if T is a ARRAY or ROW type and input values contain nested nulls.
array_sort(array: ARRAY<T>, lambda: FUNCTION(T) -> U) -> ARRAY<T>Returns the array sorted by values computed using the specified lambda in ascending order. U must be an orderable type. Null elements will be placed at the end of the returned array. May throw if T is an ARRAY or ROW type and input values contain nested nulls. Throws if deciding the order of elements would require comparing nested null values.
Example:
MATCH (n:Person) RETURN array_sort(n.friends);
MATCH (n:Person) RETURN array_sort(n.friends, x -> x.age) AS sorted_friends;array_sort_desc()
Signature:
array_sort_desc(array: ARRAY<T>) -> ARRAY<T>Returns the array sorted in descending order. T must be an orderable type. Null elements will be placed at the end of the returned array. May throw if T is an ARRAY or ROW type and input values contain nested nulls. Throws if deciding the order of elements would require comparing nested null values.
array_sort_desc(array: ARRAY<T>, lambda: FUNCTION(T) -> U) -> ARRAY<T>Returns the array sorted by values computed using the specified lambda in descending order. U must be an orderable type. Null elements will be placed at the end of the returned array. May throw if T is an ARRAY or ROW type and input values contain nested nulls. Throws if deciding the order of elements would require comparing nested null values.
Example:
MATCH (n:Person) RETURN array_sort_desc(n.friends) AS sorted_friends;
MATCH (n:Person) RETURN array_sort_desc(n.friends, x -> x.age) AS sorted_friends;transform()
Signature:
transform(array: ARRAY<T>, function: FUNCTION(T) -> U) -> ARRAY<U>Returns an array that is the result of applying the function to each element of the input array.
Example:
RETURN transform(ARRAY[0, 1], x -> x + 0.1);arrays_union()
Signature:
arrays_union(x: ARRAY<T>, y: ARRAY<T>) -> ARRAY<T>Returns an array of the elements in the union of x and y, without duplicates. For FLOAT and DOUBLE, NANs (Not-a-Number) are considered equal.
Example:
RETURN arrays_union(ARRAY[1, 2, 3], ARRAY[3, 4, 5]);size()
Signature:
size(array: ARRAY<T>) -> BIGINTReturns the number of elements in the array.
Example:
RETURN size([1, 2, 3, 4])range()
Signature:
range(start: BIGINT, end: BIGINT [, step: BIGINT]) -> ARRAY<BIGINT>Returns a array comprising all integer values within a specified range.
Example:
RETURN range(0, 10)reduce()
Signature:
reduce(accumulator = initial, variable IN array| expression) -> T| arg | type |
|---|---|
| accumulator | VARIABLE |
| initial | T |
| variable | VARIABLE |
| array | ARRAY<U> |
| expression | FUNCTION(T, U) -> T |
Applies an expression to each element in a array, carrying over the result of the computation to the next element.
Example:
RETURN reduce(total = 0, n IN [1, 2, 3, 4] | total + n)reverse()
Signature:
reverse(array: ARRAY<T>) -> ARRAY<T>Returns a array in which the order of all elements in the original array have been reversed.
Example:
RETURN reverse([1, 2, 3, 4])tail()
Signature:
tail(array: ARRAY<T>) -> ARRAY<T>Returns all elements of the array except the first one.
Example:
RETURN tail([1, 2, 3, 4])to_boolean_array()
Signature:
to_boolean_array(array: ARRAY<T>) -> ARRAY<BOOLEAN>Converts a array of values to a array of boolean values.
Example:
RETURN to_boolean_array(['true', 'false', 'true'])to_double_array()
Signature:
to_double_array(array: ARRAY<T>) -> ARRAY<DOUBLE>Converts a array of values to a array of double values.
Example:
RETURN to_double_array(['1.1', '2.2', '3.3'])to_bigint_array()
Signature:
to_bigint_array(array: ARRAY<T>) -> ARRAY<BIGINT>Converts a array of values to a array of bigint values.
Example:
RETURN to_bigint_array(['1', '2', '3'])to_varchar_array()
Signature:
to_varchar_array(array: ARRAY<T>) -> ARRAY<VARCHAR>Converts a array of values to a array of varchar values.
Example:
RETURN to_varchar_array([1, 2, 3])