array_split()
Applies to: ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Splits an array to multiple arrays according to the split indices and packs the generated array in a dynamic array.
Syntax
array_split
(array, index)
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
array | dynamic |
✔️ | The array to split. |
index | int or dynamic |
✔️ | An integer or dynamic array of integers used to indicate the location at which to split the array. The start index of arrays is zero. Negative values are converted to array_length + value . |
Returns
Returns a dynamic array containing N+1 arrays with the values in the range [0..i1), [i1..i2), ... [iN..array_length)
from array
, where N is the number of input indices and i1...iN
are the indices.
Examples
This following example shows how to split and array.
print arr=dynamic([1,2,3,4,5])
| extend arr_split=array_split(arr, 2)
Output
arr | arr_split |
---|---|
[1,2,3,4,5] | [[1,2],[3,4,5]] |
print arr=dynamic([1,2,3,4,5])
| extend arr_split=array_split(arr, dynamic([1,3]))
Output
arr | arr_split |
---|---|
[1,2,3,4,5] | [[1],[2,3],[4,5]] |