当我尝试从json文件中提取时,我收到错误:
adl在调用方法'提取'时,报告了用户代码未处理的异常。在用户类型' Microsoft.Analytics.Samples.Formats.Json.MultiLevelJsonExtractor'
我已经安装了程序集,但是当我尝试在.json文件上执行作业时,我总是收到此错误。
这是我的代码:
REFERENCE ASSEMBLY BankingADLDB.[Newtonsoft.Json];
REFERENCE ASSEMBLY BankingADLDB.[Microsoft.Analytics.Samples.Formats];
USING Microsoft.Analytics.Samples.Formats.Json;
DECLARE @in string=@"adl://xxx.azuredatalakestore.net/14-04-2018/00_0_18144c820d664dfea18583f9ce515bd3.json";
DECLARE @out string=@"Test.csv";
@result =
EXTRACT message string,
messageTypeId string,
providerTypeId string,
identifier string,
key string,
extras string
FROM @in
USING new MultiLevelJsonExtractor("TranscriptionSections[*].Sentences[*]",
false,
"message",
"messageTypeId",
"providerTypeId",
"identifier",
"key",
"extras");
OUTPUT @result
TO @out
USING Outputters.Csv();
以下是json文件的示例:
{"溶液":"大便""消息" {" messageTypeId":1," providerTypeId&#34 ;:1,"标识符":" 1-7jh88""条目":[{"键":"用户信息&# 34;,"价值":{"名称":" John Jo Carvalho","性别":"未知" "生日":""" NIF":"""电子邮件":" sample@sample.me"," phoneNumber的":&#34 + 351789582471""用户位置" {"地址":&#34 ;""镇":"里斯本""邮编":"""国家" :"葡萄牙"}" photoUrl":" https://xxx.jpg"}}],"额外":[]}, " EventProcessedUtcTime":" 2018-04-14T00:00:19.2501003Z""的partitionid":1," EventEnqueuedUtcTime":&#34 ; 2018-04-14T00:00:19.1970000Z"" IoTHub" {"的MessageId":空,"的correlationID":空,&#34 ; ConnectionDeviceId":" 1-7jh88"" ConnectionDeviceGenerationId":" 123456789123456789 "" EnqueuedTime":" 2018-04-14T00:00:19.0120000Z""流ID":空}}
答案 0 :(得分:0)
对于您提供的实际json,我能够使用略微不同的json路径进行此工作,即messages.entries[*]
:
@result =
EXTRACT
// message string,
messageTypeId string,
providerTypeId string,
identifier string,
key string,
extras string
FROM @in
//USING new MultiLevelJsonExtractor("TranscriptionSections[*].Sentences[*]",
USING new MultiLevelJsonExtractor("message.entries[*]",
true,
// "message",
"messageTypeId",
"providerTypeId",
"identifier",
"key",
"extras");
我已从message
语句中删除了EXTRACT
列,因为在json术语中它是一个包含其他项目的对象。
我的结果: