У меня есть вход JSON, который выглядит как
{ "sessionId": 1234, "deviceId": "MAC:1234", "IoTHub": { "MessageId": "1234-1234-1234-1234" } }
Как извлечь значения sessionId, deviceId и MessageId в сценарии Azure Datalake Analytics usql?
sessionId
deviceId
MessageId
.\Examples\DataFormats\Microsoft.Analytics.Samples.sln
.\Examples\DataFormats\Microsoft.Analytics.Samples.Formats\bin\Debug\Microsoft.Analytics.Samples.Formats.dll
.\Examples\DataFormats\Microsoft.Analytics.Samples.Formats\bin\Debug\Newtonsoft.Json.dll
.\assemblies
.\lib\...
Cloud Explorer
[1] GitHub Azure USQL
[2] GitHub Azure USQL DataFormats
[3] U-SQL - извлечение данных из массива json
DECLARE @localDevelopment bool = true; IF @localDevelopment == true THEN DROP ASSEMBLY IF EXISTS [Newtonsoft.Json]; DROP ASSEMBLY IF EXISTS [Microsoft.Analytics.Samples.Formats]; CREATE ASSEMBLY [Newtonsoft.Json] FROM @"/lib/Newtonsoft.Json.dll"; CREATE ASSEMBLY [Microsoft.Analytics.Samples.Formats] FROM @"/lib/Microsoft.Analytics.Samples.Formats.dll"; DECLARE @input string = @"/data/input.json"; DECLARE @output string = @"/data/output.csv"; ELSE DECLARE @input string = @"/data/input.json"; DECLARE @output string = @"/data/output.csv"; END; REFERENCE ASSEMBLY [Newtonsoft.Json]; REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats]; //Define schema of file, must map all columns //Names must match keys @extractDataFirstLevel = EXTRACT sessionId int, deviceId string, IoTHub string //Date DateTime FROM @input USING new Microsoft.Analytics.Samples.Formats.Json.JsonExtractor(); @selectData = SELECT sessionId, deviceId, Microsoft.Analytics.Samples.Formats.Json.JsonFunctions.JsonTuple(IoTHub)["MessageId"] AS messageId FROM @extractDataFirstLevel; OUTPUT @selectData TO @output USING Outputters.Csv();