Applies to: Databricks SQL Databricks Runtime 13.3 LTS and above
Returns an expanded array where elem is inserted at the index position.
Syntax
array_insert(array, index, elem)
Arguments
array: An ARRAY.
index: A non-zero INTEGER expression specifying where to insert elem. If index is negative elem is inserted relative to the end of the array.
elem: An expression of the same type as the elements of array.
Returns
An ARRAY of the same type as array.
Notes
All elements starting with index are shifted by one position to make space for elem at index.
If index is outside the cardinality of array the array is padded with NULLs.