本文介绍了Apache PIG,ELEPHANTBIRDJSON加载程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我试图使用Elephantbird json loader在输入(在这个输入中有2条记录)解析 $ b 是我的语法: register'/home/data/Desktop/elephant-bird-pig-4.1.jar ; $ b a = LOAD'/pig/tc1.log'USING com.twitter.elephantbird.pig.load.JsonLoader(' - nestedLoad')as(json:map []); b = FOREACH GENERATE flatten(json#'node_disk_lnum_1')AS node_disk_lnum_1,flatten(json#'node_disk_xfers_in_rate_sum')AS node_disk_xfers_in_rate_sum,flatten(json#'node_disk_bytes_in_rate_22') AS node_disk_bytes_in_rate_22,flatten(json#'node_disk_lnum_7')AS node_disk_lnum_7; 描述b; b描述结果: c = FOREACH b GENERATE node_disk_lnum_1; DESCRIBE c; DUMP c; 预期成果: 请帮助我缺少什么? 解决方案您的json中没有任何嵌套数据,因此请移除-nestedload a = LOAD'/pig/tc1.log'USING com.twitter.elephantbird.pig.load.JsonLoader()as(json:map []); I'm trying to parse below input (there are 2 records in this input)using Elephantbird json loaderHere is my syntax:register '/home/data/Desktop/elephant-bird-pig-4.1.jar';a = LOAD '/pig/tc1.log' USINGcom.twitter.elephantbird.pig.load.JsonLoader('-nestedLoad') as (json:map[]);b = FOREACH a GENERATE flatten(json#'node_disk_lnum_1') ASnode_disk_lnum_1,flatten(json#'node_disk_xfers_in_rate_sum') ASnode_disk_xfers_in_rate_sum,flatten(json#'node_disk_bytes_in_rate_22') ASnode_disk_bytes_in_rate_22, flatten(json#'node_disk_lnum_7') ASnode_disk_lnum_7;DESCRIBE b;b describe result:c = FOREACH b GENERATE node_disk_lnum_1;DESCRIBE c;DUMP c;Expected Result:Throwing the below errorPlease help what am I missing? 解决方案 You do not have any nested data in your json,so remove -nestedloada = LOAD '/pig/tc1.log' USING com.twitter.elephantbird.pig.load.JsonLoader() as (json:map[]); 这篇关于Apache PIG,ELEPHANTBIRDJSON加载程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 03:16