SLICE_END
All functions > ARRAY > SLICE_END
Returns the elements at multiple specified positions in an array.
Signatures
Returns: Sliced portion of the array
SLICE_END(array: ARRAY<T>, start: BIGINT, end: BIGINT, [step: BIGINT]) → ARRAY<T> sql
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<T> | Yes | The array to slice |
start | BIGINT | Yes | Starting index (0-based, negative counts from end) |
end | BIGINT | Yes | Ending index (inclusive, negative counts from end) |
step | BIGINT | No | Optional step value (default: 1, can be negative) |
Notes
- Uses Python-like slicing with inclusive end index
- Supports negative indices for counting from the end
- Optional step parameter for skipping elements
- Negative step creates reversed slices
- Returns empty array if indices are out of range
Examples
FeatureQL
SELECT
f1 := SLICE_END(ARRAY[1,2,3,4,5,6], 1, 3), -- SQL-like [1:3] (inclusive)
f2 := SLICE_END(ARRAY[1,2,3,4,5,6], 2, 4), -- SQL-like [2:4] (inclusive)
f3 := SLICE_END(ARRAY[1,2,3,4,5,6], 3, 6), -- SQL-like [3:6] (inclusive)
f4 := SLICE_END(ARRAY[1,2,3,4,5,6], 1, 6), -- Entire array [1:6]
f5 := SLICE_END(ARRAY[1,2,3,4,5,6], -2, 6), -- Negative start [-2:6]
f6 := SLICE_END(ARRAY[1,2,3,4,5,6], 1, -1), -- Negative end [1:-1] (inclusive)
f7 := SLICE_END(ARRAY[1,2,3,4,5,6], -3, -1), -- Both negative [-3:-1] (inclusive)
f8 := SLICE_END(ARRAY[1,2,3,4,5,6], 3, 3) -- Same start and end (single element)
;Result
| f1 ARRAY | f2 ARRAY | f3 ARRAY | f4 ARRAY | f5 ARRAY | f6 ARRAY | f7 ARRAY | f8 ARRAY |
|---|---|---|---|---|---|---|---|
| [1, 2, 3] | [2, 3, 4] | [3, 4, 5, 6] | [1, 2, 3, 4, 5, 6] | [5, 6] | [1, 2, 3, 4, 5, 6] | [4, 5, 6] | [3] |
On this page