azure-data-explorer - 如何使用条件执行不同的查询以在 Kusto 中查找特定子字符串?
问题描述
我是 Kusto 的初学者,我正在尝试创建一个查询,该查询fruit
基于data
包含特定子字符串的另一个 () 列返回一个不同的 () 列。
在下面的示例中,如果在列awesome
中找到“”子字符串,则返回该子字符串,如果没有,则返回但始终保持第一列的独特性。data
"found"
"not found"
let Fruit = datatable(fruit:string, data:string)
[
"apple", "awesome",
"apple", "beast",
"banana", "a beast",
"orange", "awesome cat",
"orange", "blah"
];
所以所需的输出将是:
"apple", "found",
"banana", "not found",
"orange", "found",
解决方案
一种选择是使用countif()
聚合函数,fruit
作为聚合键,如下所示:
datatable(fruit:string, data:string)
[
"apple", "awesome",
"apple", "beast",
"banana", "a beast",
"orange", "awesome cat",
"orange", "blah"
]
| summarize countif(data has 'awesome') by fruit
| project fruit, output = iff(countif_ == 0, "not found", "found")
水果 | 输出 |
---|---|
苹果 | 成立 |
香蕉 | 未找到 |
橙 | 成立 |
推荐阅读
- php - 如何在 PHP 网站上使用 Weka 进行情绪分析?
- xamarin - Xamarin 坚持主题
- javascript - 将数据从主页传递到模式内的 php 查询
- python - 如何使用 Rasterio 更改栅格的 dtype
- python - Windows 系统中的 Python os.pipe 位置
- python - 合并python数据框和嵌套列表
- c - 变量返回还是直接返回?
- javascript - 刷新页面后如何根据第一个选择的下拉菜单获取选中的复选框?
- python - Python while循环没有写入所有数据只是最后一次读取
- cypress - 如何测试柏树的反应康瓦?