kqlazure-data-explorerkusto-explorer

Kql function to append columns


I have a kusto table. I want to append column(s) to each row based on custom logic using one of the columns in the table. I tried Invoke command. It didn't work.

.create-or-alter function Test(input: string, column: dynamic ) {
// custom logic
tostring(column.value1);
}

I want to achieve something like below. Pass the column for each row and append the result

 MyTable | Invoke Test("inputString", column)

Does kql supports this ?


Solution

  • if I understand your intention correctly, you could try something like this:

    let T = datatable(a:string, b:dynamic)
    [
        "hello", dynamic({"A":1,"B":2,"value1":3}),
        "world", dynamic({"value1":4,"value2":5}),
    ]
    ;
    let F = (T:(b:dynamic)) {
        T | extend b.value1
    }
    ;
    T | invoke F()
    
    a b b_value1
    hello {
    "A": 1,
    "B": 2,
    "value1": 3
    }
    3
    world {
    "value1": 4,
    "value2": 5
    }
    4