Important

This function is considered experimental and under active development and should not be used in production.

The function must be enabled using the feature flag ArrayFunctions. See Enabling & Disabling Feature Flags.

Evaluates the function argument on all values in the array under the array argument overwriting the array. If the asArray argument is supplied, then array:eval() saves the result in an array under the given prefix. This overwrites existing arrays of that name.

The output array is always compacted, meaning that the array indices are guaranteed to be continuous, i.e. 0,1,2,....

ParameterTypeRequiredDefaultDescription
array[a]stringrequired  The array name in LogScale Array Syntax, for example for events with fields incidents[0], incidents[1], ... this would be incidents[], as in array:eval(array="incidents[]", ....
asArraystringoptional[b]value passed to the array parameter The output array.
functionNon-aggregate functionrequired  The function to be applied to each element of the array. Must write a value to a field named the same as the output array.
varstringoptional[b]input array name Name of the variable to be used in the function argument.

[a] The argument name array can be omitted.

[b] Optional parameters use their default value unless explicitly set

Hide omitted argument names for this function

Show omitted argument names for this function

array:eval() Examples

To square the value of each item in the array:

values [0] = 2
values [1] = 3
values [2] = 4

Use the following query function:

logscale
array:eval("values[]", asArray="squared[]", var=v, function={squared :=v*v})

The expected output is:

fieldvalue
squared[0]4
squared[1]9
squared[2]16