Tengo un archivo avro para cargar en Hive pero mi archivo está en binario. ¿Qué deserializador se debe usar para que el binario avro colmen?
No quiero datos binarios en la colmena sino los datos binarios decodificados.
Así es como creo mi tabla.
CREAR TABLA kst7 SERDE DE FORMATO DE FILA "org.apache.hadoop.hive.serde2.avro.AvroSerDe " ALMACENADO COMO ENTRADA "org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat" FORMATO DE SALIDA "org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat" PROPIEDADES TBL ( "avro.schema.url" = "pathtoavsc.avsc");
Cuando uso la tabla de comandos anterior se crea, los datos se cargan pero cuando hago una selección * de la tabla obtengo el siguiente error:
Error con la excepción java.io.IOException: org.apache.avro.AvroTypeException: bytes encontrados, esperando unión
archivo 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}
]
}
Respuestas
0 para la respuesta № 1Creo que estas buscando SERDEPROPERTIES
más bien que TBLPROPERTIES
ROW FORMAT SERDE "org.apache.hadoop.hive.serde2.avro.AvroSerDe"
WITH SERDEPROPERTIES ("avro.schema.url"="pathtoschema.avsc")
De lo contrario, intente seleccionar campos individuales hasta que encuentre el que está causando el error, luego inspeccione los tipos de AVSC que se están asignando a la tabla de Hive.