Categories:

Semi-structured and structured data functions (Array/Object)

ARRAY_REVERSE

Returns an array with the elements of the input array in reverse order.

Syntax

ARRAY_REVERSE( <array> )
Copy

Arguments

array

The source array.

Returns

An array containing the elements of the input array in reverse order.

Usage notes

  • If the argument is NULL, the result will be NULL.

  • When you pass a structured array to the function, the function returns a structured array of the same type.

Examples

The following example returns an array containing the elements from the input array in reverse order:

SELECT ARRAY_REVERSE([1,2,3,4]);
Copy
+--------------------------+
| ARRAY_REVERSE([1,2,3,4]) |
|--------------------------|
| [                        |
|   4,                     |
|   3,                     |
|   2,                     |
|   1                      |
| ]                        |
+--------------------------+
Language: English