ARRAY_ROTATE()

All functions > ARRAY > ARRAY_ROTATE()

Returns a new array whose elements are rotated circularly; positive amounts shift left, negative amounts shift right.

Signatures

Returns: Rotated array with the same element type

ARRAY_ROTATE(array: ARRAY<T>, amount: BIGINT) → ARRAY<T>
sql
ParameterTypeRequiredDescription
arrayARRAY<T>YesInput array
amountBIGINTYesRotation distance (left for positive, right for negative)

Notes

  • Amount is applied modulo the array length (zero-length arrays are unchanged)
  • Uses integer rotation counts only

See also

Examples

FeatureQL
SELECT
    f1 := ARRAY_ROTATE(ARRAY[1, 2, 3, 4], 1) -- Rotate left by one
;
Result
f1 ARRAY
[2, 3, 4, 1]

Last update at: 2026/05/26 17:22:09