1

我想根据数据表中Fruit具有子字符串匹配的单元格从这两个表的连接中创建一个结果Things表。

let Fruit = datatable(fruit:string) 
[
"apple", 
"banana" 
"orange" 
];
let Things = datatable(fruit:string) 
[
"anappletree",
"myoranges" 
];

我试过这样的事情:

Fruit
| join Things on $left.fruit contains $right.thing

但是得到这个错误:

Semantic Error 
join: only column entities or equality expressions are allowed in this context.

所以这里不能用contains

我如何加入这个,这样我就可以得到一个包含以下内容的表格

"apple" | "anappletree"
"banana" | ""
"orange" | "myoranges"
4

1 回答 1

3

join如果(在您的情况下 - )的左侧Fruit足够小,您可以尝试使用mv-apply

let Fruit = datatable(fruit:string) 
[
    "apple", 
    "banana",
    "orange" 
];
let Things = datatable(thing:string) 
[
    "anappletree",
    "myoranges",
    "this is not a fruit"
];
let Fruit_list = toscalar(Fruit | summarize make_list(fruit));
Things
| mv-apply fruit = Fruit_list on (where thing contains fruit)
事物 水果
苹果树 苹果
橘子

或者,在join撰写本文时仅支持相等性,您可以尝试使用交叉连接,然后使用过滤contains

let Fruit = datatable(fruit:string) 
[
    "apple", 
    "banana",
    "orange" 
];
let Things = datatable(thing:string) 
[
    "anappletree",
    "myoranges",
    "this is not a fruit"
];
Fruit
| extend dummy = 1
| join kind=inner (Things | extend dummy = 1) on dummy
| where thing contains fruit
| project-away dummy*
水果 事物
苹果 苹果树
橘子
于 2021-08-11T22:26:22.617 回答