【发布时间】:2019-04-16 07:56:15
【问题描述】:
我在我们的域中有一个查询,我无法让它工作。我使用数据表来模仿我的问题。 我正在尝试在用户定义的函数中使用投影值。
// 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))
我在这里缺少什么,我期待'| project' 对每个结果使用函数 (f)。
这里有 2 个要修改的查询。
谢谢
【问题讨论】:
-
这是自定义函数的限制,该列不能作为自定义函数的参数。你可以看看限制here
-
评论不正确。列值可以发送到用户定义函数。该示例不起作用的原因是使用带有行上下文的“toscalar()”(这意味着不能为每个行值调用 toscalar())。
-
@AlexanderSloutsky,你是对的。我只是想把它解释得更简单一点,但给出了一个错误的解释,我的错。
标签: azure azure-data-explorer kql