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
ParameterTypeRequiredDescription
arrayARRAY<T>YesThe 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 ARRAYf2 ARRAYf3 ARRAYf4 ARRAYf5 ARRAYf6 ARRAY
[5, 4, 3, 2, 1][C, B, A][world, hello][42][][2, 2, 1, 1]

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19