2

I'm using cdh5 quickstart vm and I have a file like this(not full here):

{"user_id": "kim95",
 "type": "Book",
 "title": "Modern Database Systems: The Object Model, Interoperability, and
Beyond.",
 "year": "1995",
 "publisher": "ACM Press and Addison-Wesley",
 "authors": {},
 "source": "DBLP"
}
{"user_id": "marshallo79",
 "type": "Book",
 "title": "Inequalities: Theory of Majorization and Its Application.",
 "year": "1979",
 "publisher": "Academic Press",
 "authors": {("Albert W. Marshall"), ("Ingram Olkin")},
 "source": "DBLP"
}

and I used this script:

books = load 'data/book-seded.json'
        using JsonLoader('t1:tuple(user_id:
chararray,type:chararray,title:chararray,year:chararray,publisher:chararray,source:chararray,authors:bag{T:tuple(author:chararray)})');

STORE books INTO 'book-no-seded.tsv';

the script works , but the generated file is empty, do you have any idea?

4

3 回答 3

1

最后,只有这个模式有效:如果我添加或删除与此配置不同的空格,那么我会遇到错误(我还为元组添加了“名称”,并在它为空时指定了“null”,并更改了作者之间的顺序和来源,但即使没有这种配置,它仍然是错误的)

{"user_id": "kim95", "type": "Book","title": "Modern Database Systems: The Object Model, Interoperability, and Beyond.", "year": "1995", "publisher": "ACM Press and Addison-Wesley", "authors": [{"name":null"}], "source": "DBLP"}
{"user_id": "marshallo79", "type": "Book", "title": "Inequalities: Theory of Majorization and Its Application.", "year": "1979", "publisher": "Academic Press", "authors": [{"name":"Albert W. Marshall"},{"name":"Ingram Olkin"}], "source": "DBLP"}

工作脚本是这个:

books = load 'data/book-seded-workings-reduced.json'
        using JsonLoader('user_id:chararray,type:chararray,title:chararray,year:chararray,publisher:chararray,authors:{(name:chararray)},source:chararray');

STORE books INTO 'book-table.csv';  //whether .tsv or .csv
于 2014-07-30T23:16:46.613 回答
0

尝试使用 USING org.apache.pig.piggybank.storage.JsonStorage() 将书籍存储到“book-no-seded.tsv”中;

于 2014-07-27T01:13:53.403 回答
0

您需要确保 LOAD 模式是好的。你可以尝试做一个DUMP books快速检查。

当我们在本教程http://gethue.com/hadoop-tutorials-ii-1-prepare-the-data-for-analysis/中使用 Pig JsonLoader 时,我们必须小心输入数据和模式。

于 2014-07-28T22:43:00.303 回答