Functions related to a collection of items of the same data type stored at adjacent memory locations.
Creates an array
from the list of given parameters.
array(expression, …)
Parameter
Type
Description
Required
expression
array, boolean, double, duration, ip, long, record, string, timeframe, timestamp
An element inside the array.
required
The data type of the returned value is array
.
data record()| fieldsAdd array(2, 3, 7, 7, 1)
Query result:
[2, 3, 7, 7, 1]
Returns the average of an array. Values that are not numeric are ignored. Returns 0 if there is no matching element.
arrayAvg(array)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value is double
or long
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayAvg(a)
Query result:
[2, 3, 7, 7, 1]
4
Concatenates multiple arrays into a single array. This function skips all null values and non-array input parameter values. If no array parameter input is available, it returns null.
arrayConcat(array, …)
Parameter
Type
Description
Required
array
array expression
Array expression that should be combined with others.
required
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1), b = array("hello", "world"), c = array(null, 13))| fieldsAdd arrayConcat(a, b, c)
Query result:
[2, 3, 7, 7, 1]
[hello, world]
[NULL, 13]
[2, 3, 7, 7, 1, hello, world, NULL, 13]
Returns an array where each element is the difference from the previous non-null element, when positive, otherwise it returns 0. Null elements are skipped. The first element of the returned array is null.
arrayDelta(array)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayDelta(a)
Query result:
[2, 3, 7, 7, 1]
[NULL, 1, 4, 0, 0]
Returns the array without duplicates. It sorts numbers in ascending order and strings in lexicographic order.
arrayDistinct(array)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayDistinct(a)
Query result:
[2, 3, 7, 7, 1]
[1, 2, 3, 7]
Returns the first element of an array.
arrayFirst(arrayName)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value matches the data type of the first element of the input array.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayFirst(a)
Query result:
[2, 3, 7, 7, 1]
2
Returns a flattened array.
arrayFlatten(array)
Parameter
Type
Description
Required
array
array
The array that should be flattened.
required
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1)),record(a = array(array(2, 3), array(7, 7, 1))),record(a = array(array(2, 3, null), array(record(a = 7), "7", 1)))| fieldsAdd arrayFlatten(a)
Query result:
a
arrayFlatten(a)
[2, 3, 7, 7, 1]
[2, 3, 7, 7, 1]
[[2, 3], [7, 7, 1]]
[2, 3, 7, 7, 1]
[[2
, 3
, NULL
], [a:7
, 7
, 1
]]
[2
, 3
, NULL
, a: 7
, 7
, 1
]
Returns the position of the first member in the array, which is equal to the given value.
arrayIndexOf(array, value)
Parameter
Type
Description
Required
array
array
The array expression in which the value is searched for.
required
value
expression
The primitive value to search for in the expression.
required
The data type of the returned value is long
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayIndexOf(a, 2), arrayIndexOf(a, 7), arrayIndexOf(a, 11)
Query result:
[2, 3, 7, 7, 1]
0
2
-1
Returns the last element of an array.
arrayLast(array)
Parameter
Type
Description
Required
array
array, boolean, double, duration, ip, long, record, string, timeframe, timestamp
required
The data type of the returned value matches the data type of the last element of the input array.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayLast(a)
Query result:
[2, 3, 7, 7, 1]
1
Returns position of the last member in the array, which is equal to the given value.
arrayLastIndexOf(array, value)
Parameter
Type
Description
Required
array
array
The array expression in which the value is searched for.
required
value
expression
The primitive value to search for in the expression.
required
The data type of the returned value is long
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayLastIndexOf(a, 2), arrayLastIndexOf(a, 7), arrayLastIndexOf(a, 11)
Query result:
[2, 3, 7, 7, 1]
0
3
-1
Returns the maximum (biggest) number of an array. Values that are not numeric are ignored. Returns NULL if there is no matching element.
arrayMax(array)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value matches the data type of the last element of the input array.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayMax(a)
Query result:
[2, 3, 7, 7, 1]
7
Returns the median of the members of an array. Returns null
for arrays with mixed data type.
arrayMedian(expression)
Parameter
Type
Description
Required
expression
array
The array from which to compute the median.
required
The data type of the returned value can be boolean
, double
, duration
, or timestamp
.
data record(a = array(2, 3, 7, 7, 1)),record(a = array(2m, 3m, 7m, 7m, 1m)),record(a = array(now()-2m, now()-3m, now()-7m, now()-7m, now()-1m)),record(a = array(false, true, false, true))| fieldsAdd arrayMedian(a)
Query result:
[2, 3, 7, 7, 1]
3
[120000000000, 180000000000, 420000000000, 420000000000, 60000000000]
3 min
[2024-01-12T10:58:10.927511615Z, 2024-01-12T10:57:10.927511615Z, 2024-01-12T10:53:10.927511615Z, 2024-01-12T10:53:10.927511615Z, 2024-01-12T10:59:10.927511615Z]
2024-01-12T10:57:10.927Z
[false, true, false, true]
false
Returns the minimum (smallest) number of an array. Values that are not numeric are ignored. Returns NULL if there is no matching element.
arrayMin(array)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value matches the data type of the minimum (smallest) element of the input array.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayMin(a)
Query result:
[2, 3, 7, 7, 1]
1
Replaces each element of the input array with the average of current and previous elements within the window.
arrayMovingAvg(array, window)
Parameter
Type
Description
Required
array
array
required
window
double, long
The maximum number of elements to look back at. Maximum 60.
required
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1)),record(a = array(2, null, 7, null, 1)),record(a = array(2, "3", 7, 7, 1))| fieldsAdd arrayMovingAvg(a, 2), arrayMovingAvg(a, 6)
Query result:
[2, 3, 7, 7, 1]
[2, 2.5, 5, 7, 4]
[2, 2.5, 4, 4.75, 4]
[2, NULL, 7, NULL, 1]
[2, 2, 7, 7, 1]
[2, 2, 4.5, 4.5, 3.3333333333333335]
[2, 3, 7, 7, 1]
Replaces each element of the input array with the maximum of current and previous elements within the window.
arrayMovingMax(array, window)
Parameter
Type
Description
Required
array
array
required
window
double, long
The maximum number of elements to look back at. Maximum 60.
required
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1)),record(a = array(2, null, 7, null, 1)),record(a = array(2, "3", 7, 7, 1))| fieldsAdd arrayMovingMax(a, 2), arrayMovingMax(a, 6)
Query result:
[2, 3, 7, 7, 1]
[2, 3, 7, 7, 7]
[2, 3, 7, 7, 7]
[2, NULL, 7, NULL, 1]
[2, 2, 7, 7, 1]
[2, 2, 7, 7, 7]
[2, 3, 7, 7, 1]
Replaces each element of the input array with the minimum of current and previous elements within the window.
arrayMovingMin(array, windowSize)
Parameter
Type
Description
Required
array
array
required
window
double, long
The maximum number of elements to look back at. Maximum 60.
required
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1)),record(a = array(2, null, 7, null, 1)),record(a = array(2, "3", 7, 7, 1))| fieldsAdd arrayMovingMin(a, 2), arrayMovingMin(a, 6)
Query result:
[2, 3, 7, 7, 1]
[2, 2, 3, 7, 1]
[2, 2, 2, 2, 1]
[2, NULL, 7, NULL, 1]
[2, 2, 7, 7, 1]
[2, 2, 2, 2, 1]
[2, 3, 7, 7, 1]
Replaces each element of the input array with the sum of current and previous elements within the window.
arrayMovingSum(array, windowSize)
Parameter
Type
Description
Required
array
array
required
window
double, long
The maximum number of elements to look back at. Maximum 60.
required
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1)),record(a = array(2, null, 7, null, 1)),record(a = array(2, "3", 7, 7, 1))| fieldsAdd arrayMovingSum(a, 2), arrayMovingSum(a, 6)
Query result:
[2, 3, 7, 7, 1]
[2, 5, 10, 14, 8]
[2, 5, 12, 19, 20]
[2, NULL, 7, NULL, 1]
[2, 2, 7, 7, 1]
[2, 2, 9, 9, 10]
[2, 3, 7, 7, 1]
Calculates a given percentile of an array.
arrayPercentile(expression, percentile)
Parameter
Type
Description
Required
expression
array
The array from which to compute a percentile.
required
percentile
double, long
The percentile to compute, between 0 and 100.
required
The data type of the returned value can be boolean
, double
, duration
, or timestamp
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayPercentile(a, 50), arrayPercentile(a, 99)
Query result:
[2, 3, 7, 7, 1]
3
7
Returns the array where NULL elements are removed.
arrayRemoveNulls(array)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value is array
.
data record(a = array(2, 3, null, 7, 7, 1))| fieldsAdd arrayRemoveNulls(a)
Query result:
[2, 3, NULL, 7, 7, 1]
[2, 3, 7, 7, 1]
Returns the array with elements in reversed order.
arrayReverse(array)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arrayReverse(a)
Query result:
[2, 3, 7, 7, 1]
[1, 7, 7, 3, 2]
Returns the size of an array.
arraySize(array)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value is long
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arraySize(a)
Query result:
[2, 3, 7, 7, 1]
5
Returns the array with elements sorted in ascending order by default. If you need to control the order, use the direction
parameter.
arraySort(array, direction)
Parameter
Type
Description
Required
array
array
required
direction
string
A sort order. Possible values: ascending, descending. Default: ascending.
optional
The data type of the returned value is array
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arraySort(a), arraySort(a, direction: "descending")
Query result:
[2, 3, 7, 7, 1]
[1, 2, 3, 7, 7]
[7, 7, 3, 2, 1]
Returns the sum of an array. Values that are not numeric are ignored. Returns 0 if there is no matching element.
arraySum(array)
Parameter
Type
Description
Required
array
array
required
The data type of the returned value is double
or long
.
data record(a = array(2, 3, 7, 7, 1))| fieldsAdd arraySum(a)
Query result:
[2, 3, 7, 7, 1]
20