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
See also
Examples
FeatureQL
SELECT
f1 := SLICE_END(ARRAY(1, 2, 3, 4, 5, 6), 1, 3),
f2 := SLICE_END(ARRAY(1, 2, 3, 4, 5, 6), 2, 4),
f3 := SLICE_END(ARRAY(1, 2, 3, 4, 5, 6), 3, 6),
-- Entire array [1:6]
f4 := SLICE_END(ARRAY(1, 2, 3, 4, 5, 6), 1, 6),
-- Negative start [-2:6]
f5 := SLICE_END(ARRAY(1, 2, 3, 4, 5, 6), -2, 6),
-- Negative end [1:-1] (inclusive)
f6 := SLICE_END(ARRAY(1, 2, 3, 4, 5, 6), 1, -1),
-- Both negative [-3:-1] (inclusive)
f7 := SLICE_END(ARRAY(1, 2, 3, 4, 5, 6), -3, -1),
-- Same start and end (single element)
f8 := SLICE_END(ARRAY(1, 2, 3, 4, 5, 6), 3, 3)
;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