Returns an array of the same size and type as the original array, with the elements in reverse order. Nulls are retained.
Syntax
Parameters
| Parameter | Description | Supported input types |
|---|
<array> | The array to be reversed | ARRAY of any type |
Return Type
ARRAY of the same type as the input array
Examples
The following example returns the reverse of the input array:
SELECT ARRAY_REVERSE([1, 2, 3, 6]);
| array_reverse array(int) |
|---|
| [6, 3, 2, 1] |
Rows: 1Execution time: 6.41ms
Only the outermost array is reversed for nested arrays:
SELECT ARRAY_REVERSE([[1,2,3], [4,5], NULL, [7], [8,9]]);
| array_reverse array(array(int) null) |
|---|
| [[8, 9], [7], NULL, [4, 5], [1, 2, 3]] |
Rows: 1Execution time: 5.93ms