我想对Azure Stream Analytics中的传入JSON事件和JSON参考数据执行JOIN查询。
JSON事件如下所示:
{"devicename":"12345","value":25}
JSON参考数据(简化)如下所示:
{
"Id": "configuration",
"Sites": [{
"Id": "b83939b5-6502-4140-b807-205162ac4939",
"Name": "site1",
"Location": {
"Latitude": 5.000,
"Longitude": 5.000
},
"Lines": [{
"Id": "e707a451-948a-498e-80de-d61bc448a5ef",
"Name": "line1",
"Sections": [{
"Id": "d17d762c-4291-4912-9dcf-72113c9f0b4b",
"Name": "section1",
"Sensors": [{
"Id": "S1_PL1_LS1_M1_device_001",
"Name": "sensor1",
"ExpectedAVG": 55,
"ExpectedMIN": 35,
"ExpectedMAX": 75,
"TypeOfSensor": "Humidity"
}, {
"Id": "S1_PL1_LS1_M1_device_002",
"Name": "sensor2",
"ExpectedAVG": 105,
"ExpectedMIN": 90,
"ExpectedMAX": 118,
"TypeOfSensor": "Temperature"
}]
}]
}]
}]
}
现在我想对传入的设备数据和参考数据执行JOIN。
SELECT
i.devicename as pk,
i.value as rk,
system.timestamp as time,
r.Sites.Lines.Sections.Sensors.Temperature as Temperature,
r.Sites.Lines.Sections.Sensors.Humidity as Humidity
INTO
output
FROM
IoTHubStream i
INNER JOIN
Reference r ON r.Sites.Lines.Sections.Sensors.Id = i.devicename
现在怎么办呢?问题是参考数据可以改变,我想动态处理。 我正在考虑使用WHERE语句,但我不知道这看起来如何,一些建议/帮助是非常受欢迎的。
提前致谢!
答案 0 :(得分:0)
您可以使用此页面中描述的GetArrayElements访问数组元素https://msdn.microsoft.com/en-us/library/azure/mt298451.aspx
如果您的数据更改导致无法使用GetArrayElements,请分享有关其更改的详细信息。