Slice array

Supported in: Batch, Streaming

Returns the array sliced from the first position to the second position. First position must be 1 or higher. If second position is longer than the array, the entire rest of the array will be returned.

Expression categories: Array

Declared arguments

  • Expression - Array to slice.
    Expression<Array<T>>
  • Slice begins - Array index start at 1, or from the end if start is negative. If this value is zero, expression will throw an error.
    Expression<Integer>
  • Slice length - The length of the slice. If the slice length goes beyond the end of the array, the entire rest of the array will be returned.
    Expression<Integer>

Type variable bounds: T accepts AnyType

Output type: Array<T>

Examples

Example 1: Base case

Argument values:

  • Expression: array
  • Slice begins: sliceBegins
  • Slice length: sliceLength
arraysliceBeginssliceLengthOutput
[ hello, world, out, there ]12[ hello, world ]
[ hello, world, out, there ]22[ world, out ]
[ hello, world, out, there ]10[ ]
[ hello, world, out, there ]210[ world, out, there ]
[ hello, world, out, there ]-12[ there ]

Example 2: Null case

Argument values:

  • Expression: array
  • Slice begins: sliceBegins
  • Slice length: sliceLength
arraysliceBeginssliceLengthOutput
[ hello, world, out, there ]01null
[ hello, world, out, there ]00null
[ hello, world, out, there ]1-1null
[ ]12[ ]
[ null, null ]11[ null ]