Kusto函数空参数处理:参数为Null时返回所有行,否则过滤
Kusto函数实现:根据参数是否为空返回对应结果
可以这样修改函数,利用Kusto的isnull()函数判断参数是否为null,结合逻辑或(or)实现需求:
.create-or-alter function fnGetSecurityGroups(groupType:string) { SecurityGroups | where isnull(groupType) or GroupType =~ groupType }
逻辑说明:
- 当传入的
groupType参数为null时,isnull(groupType)返回true,整个where条件成立,返回SecurityGroups表的所有行 - 当
groupType参数不为null时,isnull(groupType)返回false,此时会执行后半部分的GroupType =~ groupType,对GroupType列进行不区分大小写的匹配过滤
内容的提问来源于stack exchange,提问作者Vinny
相关产品推荐
相关产品推荐

