azure-data-factory – U-SQL无法从JSON文件中提取数据

前端之家收集整理的这篇文章主要介绍了azure-data-factory – U-SQL无法从JSON文件中提取数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图使用UsqlJSON文件提取数据.查询成功运行而不生成任何输出数据或导致“顶点失败快速错误”.

JSON文件如下所示:

{
  "results": [
    {
      "name": "Sales/Account","id": "7367e3f2-e1a5-11e5-80e8-0933ecd4cd8c","deviceName": "HP","deviceModel": "g6-pavilion","clientip": "0.41.4.1"
    },{
      "name": "Sales/Account","id": "c01efba0-e0d5-11e5-ae20-af6dc1f2c036","deviceName": "acer","deviceModel": "veriton","clientip": "10.10.14.36"
    }
  ]
}

我的U-sql脚本是

REFERENCE ASSEMBLY [Newtonsoft.Json];
REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats];

DECLARE @in string="adl://xyz.azuredatalakestore.net/todelete.json";

DECLARE @out string="adl://xyz.azuredatalakestore.net/todelete.tsv";

@trail2=EXTRACT results string FROM @in USING new Microsoft.Analytics.Samples.Formats.Json.JsonExtractor();

@jsonify=SELECT Microsoft.Analytics.Samples.Formats.Json.JsonFunctions.JsonTuple(results,"name","id","deviceName","deviceModel","clientip") AS rec FROM @trail2;

@logSchema=SELECT rec["name"] AS sysName,rec["id"] AS sysId,rec["deviceName"] AS domainDeviceName,rec["deviceModel"] AS domainDeviceModel,rec["clientip"] AS domainClientIp 
       FROM @jsonify;

OUTPUT @logSchema TO @out USING Outputters.Tsv();

解决方法

实际上,JSONExtractor支持 JSONPath中表示的rowpath参数,使您能够识别要映射到行的JSON对象或JSON数组项.因此,您可以使用JSON文档中的单个语句提取数据:
@logSchema = 
    EXTRACT name string,id string,deviceName string,deviceModel string,clientip string
    FROM @input
   USING new Microsoft.Analytics.Samples.Formats.Json.JsonExtractor("results[*]");
原文链接:https://www.f2er.com/mssql/74997.html

猜你在找的MsSQL相关文章