azure - Kusto 无法将值投影到用户定义的函数中

标签 azure azure-data-explorer kql

我在我们的域中有一个查询,但无法使其正常工作。我使用数据表来模拟我的问题。 我正在尝试在用户定义的函数中使用投影值。

// 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 个需要修改的查询。

first query

second query

谢谢

最佳答案

有一种方法可以实现此目的(无需连接),即使用 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/

相关文章:

c# - Blazor 在使用 Microsoft Identity Platform 登录后执行代码

azure - 将 azure vhd 安装到 kubernetes pod 时出错

azure - 连接字符串可以远程工作,但不能从 Azure 工作

azure-data-explorer - 我可以使用一个 kusto 函数的输出作为其他 Kusto 函数的输入吗?

azure - Kusto 查询语言 - 如何准确获取前一天的日志 7

Azure ExpressRoute 网关区域冗余网关 ARM 模板

azure - 暂时增加 Azure 数据资源管理器中 .set 引入查询的限制

azure - 是否有一个查询可以运行,以便我可以获得过去 30 天内未登录的用户列表?

azure - 如何将我的日期时间数据分为系列数据及其在 kusto 中的值

csv - 用逗号分割,但将字符串保留在双引号原子中