【发布时间】:2014-11-20 12:19:37
【问题描述】:
我在 Pig 中有一个如下所示的关系:
([account_id#100,
timestamp#1434,
id#900],
[account_id#100,
timestamp#1434,
id#901],
[account_id#100,
timestamp#1434,
id#902])
如您所见,我在一个元组中有三个地图对象。上面的所有数据都在关系中的第 0 美元字段内。因此,上面的数据与单个 bytearray 列有关。
数据加载如下:
data = load 's3://data/data' using com.twitter.elephantbird.pig.load.JsonLoader('-nestedLoad');
DESCRIBE data;
data: {bytearray}
如何将这个数据结构拆分成三行,输出如下?
data: {account_id:chararray, timestamp:chararray, id:int}
(100, 1434,900)
(100, 1434,901)
(100, 1434,902)
【问题讨论】:
-
你能提供你的文件内容吗?您提供的关系不是 JSON 格式,我无法使用 com.twitter.elephantbird.pig.load.JsonLoader 来加载它 - 我得到 0 行
-
我认为您应该为 JsonLoader 提供一个模式,请参见此处的示例:pig.apache.org/docs/r0.12.1/func.html#jsonloadstore
-
您能否提供一个数据文件,我们可以加载该文件以获取您的输入?
标签: hadoop dictionary tuples apache-pig elephantbird