用猪以不同方式阅读json

时间:2015-05-28 08:41:20

标签: dictionary schema tuples apache-pig

我的json文件

{"messages":[{"food":"Taco1", "person":"Alice1", "amount":1}]}
{"messages":[{"food":"Taco2", "person":"Alice2", "amount":2}]}
{"messages":[{"food":"Taco3", "person":"Alice3", "amount":3}]}

我的代码

STOCK_A = LOAD 'file.json' 
USING JsonLoader('messages:{(food:chararray, person:chararray, amount:int)}');
rowarr = FOREACH STOCK_A GENERATE FLATTEN(messages.(food, person,amount));

结果架构

rowarr: {null::food: chararray,null::person: chararray,null::amount: int}

预期

rowarr: {food: chararray,person: chararray,amount: int}

我怎样才能实现这一目标?任何想法

0 个答案:

没有答案