ARRAY_REVERSE()
All functions > ARRAY > ARRAY_REVERSE()
Returns the reverse of an array.
Signatures
Returns: An array with elements in reverse order
ARRAY_REVERSE(array: ARRAY<T>) → ARRAY<T> sql
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<T> | Yes | The input array to reverse |
Notes
- Reverses the order of elements in the input array
- Returns a new array where the first element becomes the last
- The original array is not modified
- Works with any array type: scalars,
ARRAY<ROW>, andARRAY<ARRAY<T>>
See also
Examples
FeatureQL
SELECT
-- Basic numeric reversal
f1 := ARRAY_REVERSE(ARRAY(1, 2, 3, 4, 5)),
-- String array reversal
f2 := ARRAY_REVERSE(ARRAY('A', 'B', 'C')),
-- Real-world example
f3 := ARRAY_REVERSE(ARRAY('hello', 'world')),
-- Single element array
f4 := ARRAY_REVERSE(ARRAY(42)),
-- Empty array
f5 := ARRAY_REVERSE(ARRAY()::BIGINT[]),
-- Array with duplicates
f6 := ARRAY_REVERSE(ARRAY(1, 1, 2, 2))
;Result
| f1 ARRAY | f2 ARRAY | f3 ARRAY | f4 ARRAY | f5 ARRAY | f6 ARRAY |
|---|---|---|---|---|---|
| [5, 4, 3, 2, 1] | [C, B, A] | [world, hello] | [42] | [] | [2, 2, 1, 1] |
On this page