Is it possible to do for multiple inputs ?
Yes, it is possible with multiple inputs. Try by using mv-apply key = input
iterates over each value in input
and tostring(key)
ensures each input key is treated as a string. In below code pack(tostring(key), b.value1)
is used, which creates { "input1": b.value1, "input2": b.value1 }
dynamically. Now make_bag()
aggregates the results into a single dynamic object per row.
let T = datatable(a:string, b:dynamic)
[
"hello", dynamic({"A":1,"B":2,"value1":3}),
"world", dynamic({"value1":4,"value2":5})
];
let input = dynamic(["input1", "input2"]);
T
| mv-apply key = input on
(
summarize new_output_column = make_bag(pack(tostring(key), b.value1))
)
Output: