我在我们的域中有一个查询,但无法使其正常工作。我使用数据表来模拟我的问题。 我正在尝试在用户定义的函数中使用投影值。
// this works
let f = (a:int) {
datatable (b:string, d:int) ["2015-12-31", 1, "2016-12-30", 2, "2014-01-05", 3]
| as dataset
| where d == a
| project b;
};
datatable (d:int) [1, 2, 3]
| as dataset
| project toscalar(f(2))
// this doesnt work, why is the 'd' not used (projected) in function q.
// if I add toscalar to the project it also doesnt work
let f = (a:int) {
datatable (b:string, d:int) ["2015-12-31", 1, "2016-12-30", 2, "2014-01-05", 3]
| as dataset
| where d == a
| project b;
};
datatable (d:int) [1, 2, 3]
| as dataset
| project toscalar(f(d))
我在这里缺少什么,我期望 '|项目'对每个结果使用函数 (f)。
这里有 2 个需要修改的查询。
谢谢
最佳答案
有一种方法可以实现此目的(无需连接),即使用 toscalar() 创建动态映射(属性包),然后将其用作查找字典。
let f = (a:int) {
let _lookup = toscalar
(
datatable (b:string, d:int) ["2015-12-31", 1, "2016-12-30", 2, "2014-01-05", 3]
| extend p = pack(tostring(d), b)
| summarize make_bag(p)
);
_lookup[tostring(a)]
};
datatable (d:int) [1, 2, 3]
| project result=f(d)
关于azure - Kusto 无法将值投影到用户定义的函数中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55703226/