从键和值列表中创建一个 属性 包
Make a property bag from a list of keys and values
我有一个包含键的列表和另一个包含值的列表(通过拆分日志行获得)。如何将两者结合起来在 Kusto 中制作一个 proeprty-bag?
let headers = pack_array("A", "B", "C");
datatable(RawData:string)
[
"1,2,3",
"4,5,6",
]
| expand fields = split(RawData, ",")
| expand dict = ???
预计:
dict
-----
{"A": 1, "B": 2, "C": 3}
{"A": 4, "B": 5, "C": 6}
这是一个选项,它使用以下组合:
mv-apply
: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/mv-applyoperator
pack()
: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/packfunction
make_bag()
: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/make-bag-aggfunction
let keys = pack_array("A", "B", "C");
datatable(RawData:string)
[
"1,2,3",
"4,5,6",
]
| project values = split(RawData, ",")
| mv-apply with_itemindex = i key = keys to typeof(string) on (
summarize dict = make_bag(pack(key, values[i]))
)
values
dict
[
"1",
"2",
"3"
]
{
"A": "1",
"B": "2",
"C": "3"
}
[
"4",
"5",
"6"
]
{
"A": "4",
"B": "5",
"C": "6"
}
我有一个包含键的列表和另一个包含值的列表(通过拆分日志行获得)。如何将两者结合起来在 Kusto 中制作一个 proeprty-bag?
let headers = pack_array("A", "B", "C");
datatable(RawData:string)
[
"1,2,3",
"4,5,6",
]
| expand fields = split(RawData, ",")
| expand dict = ???
预计:
dict
-----
{"A": 1, "B": 2, "C": 3}
{"A": 4, "B": 5, "C": 6}
这是一个选项,它使用以下组合:
mv-apply
: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/mv-applyoperatorpack()
: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/packfunctionmake_bag()
: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/make-bag-aggfunction
let keys = pack_array("A", "B", "C");
datatable(RawData:string)
[
"1,2,3",
"4,5,6",
]
| project values = split(RawData, ",")
| mv-apply with_itemindex = i key = keys to typeof(string) on (
summarize dict = make_bag(pack(key, values[i]))
)
values | dict |
---|---|
[ "1", "2", "3" ] |
{ "A": "1", "B": "2", "C": "3" } |
[ "4", "5", "6" ] |
{ "A": "4", "B": "5", "C": "6" } |