0

我想将表 1 扩展为 IsAvailableInTable2 = Yes,如果表 2 的 MonitorId 列中存在与 Id(表 1 中的列)匹配的值。我尝试使用 materialize,但效果不佳。

//Table 1
datatable(Id:string, MetadataKey:string, MetadataValue:string, Key:string, Value:string)
[
    "Restarting", "", "", "", "", 
    "Starting", "", "", "", "", 
    "Failed", "Location", "Monitor", "Routing", "xyz", 
]
//Table 2
datatable(MonitorId:string, Automitigated:long, AlertCount:long)
[
    "Restarting", 94, 94, 
    "Restart", 93, 93, 
    "Failed", 92, 92, 
]

预期结果:

在此处输入图像描述

4

1 回答 1

2

这应该有效:

// creating the first table. optional, assuming the data is ingested, and not a 'datatable' literal
.set T1 <| datatable(Id:string, MetadataKey:string, MetadataValue:string, Key:string, Value:string)
[
    "Restarting", "", "", "", "", 
    "Starting", "", "", "", "", 
    "Failed", "Location", "Monitor", "Routing", "xyz", 
]


// creating the second table. optional, assuming the data is ingested, and not a 'datatable' literal
.set T2 <| datatable(MonitorId:string, Automitigated:long, AlertCount:long)
[
    "Restarting", 94, 94, 
    "Restart", 93, 93, 
    "Failed", 92, 92, 
]

// query
T1
| extend IsAvailableInTable2 = case(Id in ((T2 | project MonitorId)), "Yes", "No")
ID 元数据密钥 元数据值 钥匙 价值 IsAvailableInTable2
重启 是的
开始
失败的 地点 监视器 路由 xyz 是的
于 2022-02-01T20:52:23.247 回答