Kusto !has_any | 其中 value 在 set 中不包含任何值

tec*_*n23 3 kql azure-data-explorer

Kusto 中是否有内置方法来检查一个值是否不包含多个项目?我知道我可以使用 has_any 来检查一个项目是否包含集合中的任何值,但我似乎无法让它与“!”一起工作。操作员。例子:

let Employees = datatable(Id:int, Name:string, Position:string ) 
[
   1, "Bob", "General Manager",
   2, "Mary", "Coordinator",
   3, "John", "Sales Representitive"
];
Employees
| where Position !has_any("Manager", "Sales")
Run Code Online (Sandbox Code Playgroud)

预期输出:

预期输出

如果我删除非运算符 (!),它会起作用,并返回 Bob 和 John 的信息。但我想扭转它具有任何/包含的任何以不包含任何。我也试过

| where Position has_any !("Manager", "Sales")
Run Code Online (Sandbox Code Playgroud)

但它似乎是 has_any 和“!”的任意组合。抛出语法错误并且不会运行。有没有办法在不列出单个 !contains 语句的情况下做到这一点?即这不是我要找的:

| where Position !contains "Manager" and Position !contains "Sales"
Run Code Online (Sandbox Code Playgroud)

这对于两个条件来说并不是什么大问题,但是当您处理一长串列表时,最好使用 has_any 并在其前面加上一个简单的感叹号。

Yon*_*i L 6

你可以使用not()https : //docs.microsoft.com/en-us/azure/data-explorer/kusto/query/notfunction

例如:

let Employees = datatable(Id:int, Name:string, Position:string ) 
[
   1, "Bob", "General Manager",
   2, "Mary", "Coordinator",
   3, "John", "Sales Representitive"
];
Employees
| where not(Position has_any("Manager", "Sales"))
Run Code Online (Sandbox Code Playgroud)

  • 谢谢约尼!我之前尝试过`| where Position not(has_any("Manager", "Sales"))` 不起作用,但你得到了语法魔法 (4认同)
  • 不运行也很好用!````员工| 其中 not((“Coordinator”) 中的位置)``` (2认同)