insert_item
insert_item(arr: array, idx: int64, val: storable) -> generic array
Returns an array containing all elements from the source array as well as the new element.
The new element is inserted at position idx. The original element from this position (if any) and all subsequent elements (if any) are shifted by one position to the right in the resulting array. The length of the array increases by one item.
A negative position is interpreted as an index from the back of the array (e.g. -1 results in insertion before the last element in the array).
Domain
This is a scalar function (calculates a single output value for a single input row).
Categories
Examples
make_col foo:array(parse_json('[1,2,4]'))
make_col bar:insert_item(foo, 2, 3)
// foo
// [1,2,3,4]
Inserts the integer 3 into the array in column foo at index 2 (zero-based index). The result is stored in column bar.
Updated 8 days ago