【问题标题】:Comparison in UDF in Kusto on tabular dataKusto 中 UDF 在表格数据上的比较
【发布时间】:2021-10-14 20:44:40
【问题描述】:

我正在尝试使用 Kusto 中的表格并将用户定义的函数应用于各个列。 在下面的查询中:我从 JSON 类型的表中获取两列,并比较它们是否相等。

let MyFilter = (X:(x:dynamic, y:dynamic)) {
    X |  where isnotempty(tostring(x[0].key)) and isnotempty(tostring(y[0].key)) and x[0].key == y[0].key ;
};
tabl
| where MyFilter(ObjJson,ObjJson1) == true

但是,此代码似乎不起作用。有人可以帮忙吗?

【问题讨论】:

    标签: azure kql kusto-explorer


    【解决方案1】:

    尝试使用invoke 运算符:https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/invokeoperator

    let MyFilter = (X:(x:dynamic, y:dynamic)) {
        X
        | where isnotempty(tostring(x[0].key)) and 
                isnotempty(tostring(y[0].key)) and 
                tostring(x[0].key) == tostring(y[0].key)
    };
    table
    | invoke MyFilter()
    

    【讨论】:

    • 非常感谢。我试过这样做,但因为数据是 JSON 格式。我收到另一个错误:无法在没有显式转换的情况下比较动态值
    • 您是否尝试将x[0].key == y[0].key 替换为tostring(x[0].key) == tostring(y[0].key),如答案所示? (tostring() 应根据您希望在动态负载中具有的实际数据类型进行替换)
    猜你喜欢
    • 1970-01-01
    • 2015-09-03
    • 2012-06-10
    • 1970-01-01
    • 2015-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多