gpt4 book ai didi

hadoop - Hive是否可以将Avro字节反序列化为提供的架构?

转载 作者:行者123 更新时间:2023-12-02 20:49:05 25 4
gpt4 key购买 nike

我有一个Avro文件要加载到Hive中,但是我的文件是二进制文件。
应该使用哪种解串器来使二进制Avro hive 化?

我不想要 hive 中的二进制数据,而是解码后的二进制数据。

这就是我创建表格的方式。

创建表kst7
行格式序列
'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
存储为INPUTFORMAT
'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
输出格式
'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
TBLPROPERTIES(
'avro.schema.url'='pathtoavsc.avsc');

当我使用上述命令创建表时,会加载数据,但是当我从表中执行select *时,会出现以下错误:

失败,发生异常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}
]
}

最佳答案

我认为您正在寻找SERDEPROPERTIES而不是TBLPROPERTIES

ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
WITH SERDEPROPERTIES ('avro.schema.url'='pathtoschema.avsc')

否则,请尝试选择单个字段,直到找到导致错误的字段为止,然后检查将AVSC映射为Hive表的类型。

关于hadoop - Hive是否可以将Avro字节反序列化为提供的架构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46699235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com