Array element

Supported in: Batch, Streaming

Returns the element at a given position from the input array. Positions outside of the array will return null.

Expression categories: Array

Declared arguments

  • Array - Array from which to extract element.
    Expression<Array<T>>
  • Position - Position of element to extract from array. First element is at position 1. If position is negative, accesses elements from last to first (example: -1 will return last element).
    Expression<Integer>

Type variable bounds: T accepts AnyType

Output type: T

Examples

Example 1: Base case

Argument values:

  • Array: [ 10, 11, 12 ]
  • Position: 1

Output: 10


Example 2: Null case

Description: Output null if position greater than array length. Argument values:

  • Array: [ 1, 2, 4 ]
  • Position: 10

Output: null


Example 3: Null case

Description: Index array from the end using negative index. Argument values:

  • Array: [ 1, 2, 4 ]
  • Position: -1

Output: 4


Example 4: Null case

Argument values:

  • Array: array
  • Position: position
arraypositionOutput
[ 1, 2, 3 ]nullnull
null1null
nullnullnull

Example 5: Edge case

Argument values:

  • Array: array
  • Position: position
arraypositionOutput
[ 1, 2, 3 ]0null