azure-data-explorerkql

Kusto query map through array


I'm trying to map through Kusto dynamic array but I can't seem to find a specific function that can be used in Kusto's library function.

Here's my attempt so far:

let ArrayMap = (arr: dynamic) {
    range x from 0 to array_length(arr) - 1 step 1
    | summarize x = make_list(strcat('--', arr[x], '--'))
};
ArrayMap(dynamic(["a", "b", "c"]))

The problem with my attempt is that I am getting a table as the returned result instead of a dynamic array. Any help would be appreciated, thanks!


Solution

  • You can convert your table to a scalar.

    let ArrayMap = (arr: dynamic) {
        toscalar (
        range x from 0 to array_length(arr) - 1 step 1
        | summarize x = make_list(strcat('--', arr[x], '--'))
        )
    };
    print(ArrayMap(dynamic(["a", "b", "c"])))