我试图使用Kusto在Azure应用程序见解中简单地运行子查询,以便我可以从显示为一个的两个表中获取一些信息。
我正在尝试的查询是
table1
| extend progressLog = toscalar(
table2
| where common_Id == table1.common_Id // errors saying Ensure that expression: table1.common_Id is indeed a simple name
| summarize makelist(stringColumn)
)
我试图给这个ID加上别名,甚至像这样将两个表连接起来:
requests
| extend aliased_id = common_Id
| join traces on operation_Id, $left.operation_Id == $right.operation_Id
| extend test_id = operation_Id
| extend progressLog = toscalar(
traces
| where operation_Id == aliased_id // Failed to resolve column or scalar expression named 'aliased_id'
| summarize makelist(message)
)
无法解析名为“ aliased_id”的列或标量表达式。
我只是想做与T-SQL查询等效的事情:
SELECT
... ,
STRING_AGG(table2.stringColumn, ',')
FROM
table1
INNER JOIN
table2
ON table1.common_Id = table2.common_Id
GROUP BY
table.<props>
我的主要问题是-如何在子查询中引用库斯托语言的“ common_Id”
答案 0 :(得分:0)
请查看下一个查询是否提供您想要的内容。如果没有,请像下面一样使用数据表共享示例输入,并提供预期的输出:
let requests = datatable(common_Id:string, operation_Id:string)
[
"A", "X",
"B", "Y",
"C", "Z"
];
let traces = datatable(operation_Id:string, message:string)
[
"X", "m1",
"X", "m2",
"Y", "m3"
];
let messagesByOperationId = traces | summarize makelist(message) by operation_Id;
requests
| join kind=leftouter messagesByOperationId on operation_Id
| project common_Id, operation_Id, progressLog = list_message