【发布时间】:2018-03-23 18:41:46
【问题描述】:
我有要加载到 Hive 的 avro 文件,但我的文件是二进制文件。 应该使用什么反序列化器来让二进制 avro 进入 hive?
我不想要 hive 中的二进制数据,而是解码后的二进制数据。
这就是我创建表格的方式。
创建表 kst7 行格式SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' 存储为输入格式 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' 输出格式 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' TBL 属性 ( 'avro.schema.url'='pathtoavsc.avsc');
当我使用上面的命令创建表时,会加载数据,但是当我从表中选择 * 时出现以下错误:
异常 java.io.IOException:org.apache.avro.AvroTypeException 失败:找到字节,期待联合
avsc 文件:
{
"namespace": "com.nimesh.tripod.avro.enrichment",
"type": "record",
"name": "EnrichmentData",
"fields": [
{"name": "rowKey", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
{"name": "ownerGuid", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
{"name": "autotagsEnrichment", "type": ["bytes", "null", {
"namespace": "com.nimesh.tripod.avro.enrichment",
"type": "record",
"name": "AutotagEnrichment",
"fields": [
{"name": "version", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
{"name": "autotags", "type": ["null", {"type": "array", "items": {
"namespace": "com.nimesh.tripod.avro.enrichment",
"type": "record",
"name": "Autotag",
"fields": [
{"name": "tag", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
{"name": "score", "type": ["null", "double"], "default": null}
]
}}], "default": null}
]
}], "default": null},
{"name": "colorEnrichment", "type": ["bytes","null", {
"namespace": "com.nimesh.tripod.avro.enrichment",
"type": "record",
"name": "ColorEnrichment",
"fields": [
{"name": "version", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
{"name": "color", "type": ["null", {"type": "array", "items": {
"namespace": "com.nimesh.tripod.avro.enrichment",
"type": "record",
"name": "Color",
"fields": [
{"name": "color", "type": ["null", {"type":"string","avro.java.string":"String"}], "default": null},
{"name": "score", "type": ["null", "double"], "default": null}
]
}}], "default": null}
]
}], "default": null}
]
}
【问题讨论】: