使用pig从mongo读取未命名的字符串数组

fiei3ece  于 2021-06-25  发布在  Pig
关注(0)|答案(1)|浏览(314)

我有一个记录,在蒙哥如下。

{ "_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,汽车:{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)}}

有人能帮我写一下装货单吗?

wsewodh2

wsewodh21#

看看这里:
将mongo数组转化为pig元组。

相关问题