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 (numbers, strings, etc.)
Examples
FeatureQL
SELECT
f1 := ARRAY_REVERSE(ARRAY[1, 2, 3, 4, 5]), -- Basic numeric reversal
f2 := ARRAY_REVERSE(ARRAY['A', 'B', 'C']), -- String array reversal
f3 := ARRAY_REVERSE(ARRAY['hello', 'world']), -- Real-world example
f4 := ARRAY_REVERSE(ARRAY[42]), -- Single element array
f5 := ARRAY_REVERSE(ARRAY[]::BIGINT[]), -- Empty array
f6 := ARRAY_REVERSE(ARRAY[1, 1, 2, 2]) -- Array with duplicates
;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