Я хочу отфильтровать имя, страну, провинцию, город, OsVersion, RoleName, категорию снизу json.
[{"event":
[{"name":"4.8","count":1}],
"internal":{"data":{"id":"da3d8290-41f4-11e8-a8f8-e347c81391d3","documentVersion":"1.61"}},
"context":{
"data":{"eventTime":"2018-04-17T04:08:27.392Z","isSynthetic":false,"samplingRate":100.0},
"cloud":{},
"device":{"type":"PC","osVersion":"Microsoft Windows NT 6.1.7601 Service Pack 1","roleName":"Connexx","roleInstance":"Connexx","screenResolution":{}},
"session":{"isFirst":false},
"operation":{},
"location":{"clientip":"0.0.0.0","continent":"Asia","country":"Singapore"},
"custom":{"dimensions":[{"Category":"Noah Version"},{"ai.device.language":"en-US"},{"RAMSize":"7.88622283935547"},{".NetVersion":"4.6.2"},{"64BitProcess":"False"},{"64BitOS":"True"},{"ProcessorCount":"4"}]}
}
}]
Я использую приведенный ниже код, но не получаюИмя.
// A. CREATE ASSEMBLY: Register assemblies (if they do not already exist).
CREATE ASSEMBLY IF NOT EXISTS [Newtonsoft.Json] FROM @"/Assemblies/Newtonsoft.Json.dll";
CREATE ASSEMBLY IF NOT EXISTS [Microsoft.Analytics.Samples.Formats] FROM @"/Assemblies/Microsoft.Analytics.Samples.Formats.dll";
// B. REFERENCE ASSEMBLY: Load assemblies for compile time and execution.
REFERENCE ASSEMBLY [Newtonsoft.Json];
REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats];
// C. USING: Specify namespace to shorten function names (e.g. Microsoft.Analytics.Samples.Formats.Json.JsonExtractor)
USING Microsoft.Analytics.Samples.Formats.Json;
DECLARE @InputFile string = @"/TransformedBlobData/Source/{*}";
DECLARE @output string = @"/TransformedBlobData/OutputVatan/transBlobOutput13.csv";
@json =
EXTRACT [event] String,
location String,
device String,
custom String
FROM @InputFile
USING new Microsoft.Analytics.Samples.Formats.Json.JsonExtractor("context");
@CreateJSONTuple =
SELECT JsonFunctions.JsonTuple([event], "event[0]") AS EventData,
JsonFunctions.JsonTuple(location) AS LocationData,
JsonFunctions.JsonTuple(device) AS DeviceData,
JsonFunctions.JsonTuple(custom, "dimensions[0]") AS DimensionData0,
JsonFunctions.JsonTuple(custom, "dimensions[1]") AS DimensionData1,
JsonFunctions.JsonTuple(custom, "dimensions[2]") AS DimensionData2,
JsonFunctions.JsonTuple(custom, "dimensions[100]") AS DimensionData100 //Just to see what happen if we go out of range, and it dont give exception
FROM @json;
@result =
SELECT EventData AS NameCount,
//EventData["[name]"] ?? "N/A" AS NameCount,
LocationData["country"] ?? "N/A" AS Country,
LocationData["province"] ?? "N/A" AS Province,
LocationData["city"] ?? "N/A" AS City,
DeviceData["osVersion"] ?? "N/A" AS OsVersion,
DeviceData["roleName"] ?? "N/A" AS RoleName,
DimensionData0["dimensions[0]"] AS CategoryDimension0,
DimensionData1["dimensions[1]"] AS CategoryDimension1,
DimensionData2["dimensions[2]"] AS CategoryDimension2,
DimensionData2["dimensions[100]"] AS CategoryDimension100
FROM @CreateJSONTuple;
@result =
SELECT NameCount["name"] ?? "N/A" AS Name,
Country,
Province,
City,
OsVersion,
RoleName,
JsonFunctions.JsonTuple(CategoryDimension0) AS CategoryDimension0,
JsonFunctions.JsonTuple(CategoryDimension1) AS CategoryDimension1,
JsonFunctions.JsonTuple(CategoryDimension2) AS CategoryDimension2,
JsonFunctions.JsonTuple(CategoryDimension100) AS CategoryDimension100
FROM @result;
@result =
SELECT Name,
Country,
Province,
City,
OsVersion,
RoleName,
CategoryDimension0["Category"] ?? CategoryDimension1["Category"] ?? CategoryDimension2["Category"] ?? CategoryDimension100["Category"] ?? "N/A" AS Category
FROM @result
WHERE Country != "N/A"
;
OUTPUT @result
TO @output
USING Outputters.Csv(outputHeader : true, quoting : true);
Я не получаю event.name, и он приходит как N / A.Пожалуйста, помогите Это выводит: «N / A» «Сингапур» «N / A» «N / A» «Microsoft Windows NT 6.1.7601 с пакетом обновления 1» «Connexx» «Noah Version»