【问题标题】:How to access a value from a user defined function which returns tabular output in kusto如何从用户定义的函数访问值,该函数在 kusto 中返回表格输出
【发布时间】:2021-02-15 13:41:37
【问题描述】:

我有以下用户定义功能

let myFunction = ()
{
T
| where id ==12345
|mv-expand details.data
|extend CreateTime=todatetime(details_data.["time"])
|extend Code=tostring(details_data.code)
|summarize arg_max(CreateTime,Code)
};

现在我想从上面的函数中获取每一列的值,该函数返回 1 行和 2 个 cloumns 类似 |打印 T().CreateTime |打印 T().代码

你能帮我实现上述目标吗?

【问题讨论】:

  • 嗨,Gurdeep,下面的答案能回答问题吗?如果是,请接受 :) 如果不是,请添加评论,说明您缺少什么。

标签: azure-data-explorer kql


【解决方案1】:

toscalar() 函数将完全满足您的需求:

例子:

let SomeResult =
    range n from 1 to 1000 step 1
    | extend r = 100 * rand()
    | summarize min(r), max(r), avg(r);
print toscalar(SomeResult | project min_r)

结果将是:

print_0
0.0437954709718918

请注意,访问特定列中的值是使用 project 运算符完成的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-29
    • 1970-01-01
    • 2019-09-11
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多