3

我有一个在 mongo 中如下所示的记录。

{ "_id" : ObjectId("..."), "gender":"male", "age" : 19, "cars" : ["a", "b", "c"], "first" : "Daniel", "last" : "Alabi" }

{ "_id" : ObjectId("..."), "gender":"male", "age" : 21, "cars" : ["d", "e"], "first" : "Tolu", "last" : "Alabi" }

{ "_id" : ObjectId("..."), "gender":"female", "age" : 50, "cars" : [], "first" : "Tinuke", "last" : "Dada" }

在猪中加载数据后,我希望将架构设置为'f:chararray,l:chararray,g:chararray,age:int,cars:{t:(car:chararray)}'。

我尝试使用

TEMP = LOAD 'mongodb://localhost:27017/local.temp' USING com.mongodb.hadoop.pig.MongoLoader('first:chararray, last:chararray, age:int, gender:chararray, cars:{(chararray)}');

DESCRIBE TEMP;

我得到的输出为

(Daniel,Alabi,19,male,)

(Tolu,Alabi,21,male,)

(Tinuke,Dada,50,female,{})

TEMP: {first: chararray,last: chararray,age: int,gender: chararray,cars: {(val_0: chararray)}}

有人可以帮忙写负载声明吗?

4

1 回答 1

0

看看这里

Mongo 数组被转换为 Pig Tuple。

于 2013-11-12T13:05:01.353 回答