我在编写查询以从 json 文件中的数组中提取表时遇到问题:问题是如何获取数组“clientPerformance”的信息,然后将它们全部放入普通的 SQL 表中。
该文件如下所示:
"clientPerformance":[
{
"name":"opportunity",
"clientProcess":{
"value":3620000.0,
"count":1.0,
"min":3620000.0,
"max":3620000.0,
"stdDev":0.0,
"sampledValue":3620000.0
},
"networkConnection":{
"value":10000.0,
"count":1.0,
"min":10000.0,
"max":10000.0,
"stdDev":0.0,
"sampledValue":10000.0
},
"receiveRequest":{
"value":9470000.0,
"count":1.0,
"min":9470000.0,
"max":9470000.0,
"stdDev":0.0,
"sampledValue":9470000.0
},
"sendRequest":{
"value":1400000.0,
"count":1.0,
"min":1400000.0,
"max":1400000.0,
"stdDev":0.0,
"sampledValue":1400000.0
},
"total":{
"value":14500000.0,
"count":1.0,
"min":14500000.0,
"max":14500000.0,
"stdDev":0.0,
"sampledValue":14500000.0
},
"url":"https://xxxx",
"urlData":{
"base":"/main.aspx",
"host":"xxxx",
"hashTag":"",
"protocol":"https"
}
}
]
我尝试使用获取数组元素方法和其他方法,但我永远无法访问 clientProcess、networkConnection.. elements
我尝试使用这个例子:
Select
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 0), 'name') AS Name,
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 1), 'clientProcess.count') AS clientProcessCount,
FROM [app-insights-blob-dev] Input
如果有任何帮助,我将不胜感激:)
最佳答案
我稍微编辑了您的查询以返回 clientProcessCount。 (我将数组索引从 1 更改为 0)。另请确保您的 JSON 对象以 { 开头并以 } 结尾。
Select
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 0), 'name') AS Name,
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 0), 'clientProcess.count') AS clientProcessCount
FROM [app-insights-blob-dev] Input
有关使用 ASA 查询复杂对象的其他示例,请随时查看此 blog post .
关于json - Azure 流分析查询 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47870907/