如何在连续查询中访问多个Kusto let语句的结果?

huangapple go评论50阅读模式
英文:

How to access multiple kusto let statement results in a consecutive query?

问题

我想查询在执行之前bin()函数的输入值,其中三个点(...)表示一个整数变量:

在ADX中,通过悬停在变量上方,可以查看bin_size,如下图所示:

因此,我认为我可以访问变量y_bin_sizex_bin_size来进行我的最终查询。

如何访问第一个let查询的内部结果?
是否可以将这个操作合并成一个查询?

非常感谢。

英文:

I'd like to query the input value for the bin() function prior to the execution, in which the three dots (...) represent a integer variable:

let bin_size = 
T 
| project X, Y
| summarize y_bin_size=(max(Y) - min(Y)) / ..., x_bin_size=(max(X) - min(X)) / ...;
let result = 
T
| project X, Y
| summarize Count=count() by bin(X, bin_size.x_bin_size), bin(Y, bin_size.y_bin_size);
result

In ADX the bin_size is shown by hovering over the variable, as shown in the image:

如何在连续查询中访问多个Kusto let语句的结果?

Therefore, I suppose, I could access the variables y_bin_size and x_bin_size for my final query.

How can I access the inner results of the first let query?
Can I combine this in one query?

Thanks a lot.

答案1

得分: 1

你可以尝试类似以下方式:

  1. 在查询的第一部分:计算并存储类型为 dynamic 的标量属性包中的分箱大小。
  2. 在查询的另一部分中,访问属性(xy)从步骤 1 中的属性包中。
let bin_sizes = toscalar(
    T
    | summarize bag_pack("y", (max(Y) - min(Y)) / 5,
                         "x", (max(X) - min(X)) / 6)
)
;
let result = 
    T
    | summarize Count=count() by
          bin(X, todouble(bin_sizes.x)),
          bin(Y, todouble(bin_sizes.y))
;
result
英文:

you could try something like this:

  1. in the first part of the query: calculate and store the bin sizes in a scalar property bag of type dynamic.
  2. access the properties (x and y) from the bag in #1 in the other part of your query.
let bin_sizes = toscalar(
    T
    | summarize bag_pack("y", (max(Y) - min(Y)) / 5,
                         "x", (max(X) - min(X)) / 6)
)
;
let result = 
    T
    | summarize Count=count() by
          bin(X, todouble(bin_sizes.x)),
          bin(Y, todouble(bin_sizes.y))
;
result
``

</details>



huangapple
  • 本文由 发表于 2023年2月10日 04:33:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75404145.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定