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
ParameterTypeRequiredDescription
arrayARRAY<T>YesThe array to slice
startBIGINTYesStarting index (0-based, negative counts from end)
endBIGINTYesEnding index (inclusive, negative counts from end)
stepBIGINTNoOptional 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 ARRAYf2 ARRAYf3 ARRAYf4 ARRAYf5 ARRAYf6 ARRAYf7 ARRAYf8 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]

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