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
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<T> | Yes | Input array |
amount | BIGINT | Yes | Rotation 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] |
On this page