Data connectivity & integrationPipeline Builder ExpressionsArray add

Array add

Supported in: Batch, Streaming

Adds a value to the array at a specified index.

Expression categories: Array

Declared arguments

  • Array - The array to add an element to.
    Expression<Array<T>>
  • Index - Position where the new element should be inserted into the array. First element is at position 1.
    Expression<Integer>
  • Value - The element to add to the array.
    Expression<T>

Type variable bounds: T accepts AnyType

Output type: Array<T>

Examples

Example 1: Base case

Argument values:

  • Array: numbers
  • Index: 1
  • Value: 1
numbersOutput
[ 3, 5 ][ 1, 3, 5 ]
[ 2 ][ 1, 2 ]
[ ][ 1 ]

Example 2: Null case

Argument values:

  • Array: numbers
  • Index: index
  • Value: value
numbersvalueindexOutput
null11null
[ 1 ]null1[ null, 1 ]
[ 1 ]1null[ 1 ]

Example 3: Edge case

Argument values:

  • Array: numbers
  • Index: 10
  • Value: 1
numbersOutput
[ 3, 5 ][ 3, 5, null, null, null, null, null, null, null, 1 ]