このバッグ構造を持つJSONファイルを操作しようとしています:
{
"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"
}
serde を使用して、Hive の JSON データをロードしようとしました。ここで見た両方の方法に従いました:http://blog.cloudera.com/blog/2012/12/how-to-use-a-serde-in-apache-hive/
このコードで:
CREATE EXTERNAL TABLE IF NOT EXISTS serd (
user_id:string,
type:string,
title:string,
year:string,
publisher:string,
authors:array<struct<name:string>>,
source:string)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
LOCATION '/user/hdfs/data/book-seded_workings-reduced.json';
このエラーが発生しました:
error while compiling statement: failed: parseexception line 2:17 cannot recognize input near ':' 'string' ',' in column type
私もこのバージョンを試しました: https://github.com/rcongiu/Hive-JSON-Serde
別のエラーが発生しました:
Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Cannot validate serde: org.openx.data.jsonserde.JsonSerde
何か案が?
また、「作成者」の「名前」フィールドでクエリを作成するために、このような JSON を操作するための代替手段を知りたいです。豚かハイブか?
すでに「tsv」ファイルに変換しています。しかし、著者の列はタプルなので、このファイルからテーブルを作成する場合、Hive で 'name' をリクエストする方法がわかりません。「tsv」変換用にスクリプトを変更するか、そのままにしておく必要がありますか? または、Hive または Pig の代替手段はありますか?