在Kusto中有case函数吗?



Azure Data Explorer中的MmsPoolProperty表中没有列说明池类型,因此我需要从池名称中提取子字符串以检查池是内部还是公共。

如果池名包含子字符串"imc"它是私有的,并且包含"pmc"或";ghmc"是公众。

MmsPoolProperty
| where TIMESTAMP > ago(1d)
| where ImageName contains "mac" or ImageName contains "osx"
| summarize arg_max(TIMESTAMP, AllPropertiesBlob) by PoolName // We can get rid of this once the decoupling has been rolled out for long enough that we don't have old telemetry
| extend props = parse_json(AllPropertiesBlob)
| project PoolName, UnitName = coalesce(props["VmControllerName"], PoolName) 
| extend PoolType = case(PoolName contains "imc","Internal",
PoolName contains "pmc","Public",
PoolName contains "ghmc","Public")

case()函数需要一个默认值作为最后一个参数,在末尾添加如下内容:

| extend PoolType = case(PoolName contains "imc","Internal",
PoolName contains "pmc","Public",
PoolName contains "ghmc","Public",
"Unknown")

最新更新