3

I am facing a problem where I have updated the namespace in my avsc schema file. Since we were using common processor created in Java to parse the XML to avro and were using the avsc file.

We have separated the interfaces and created 2 different namespaces and now having 2 avsc schemas which are identical just the namespace is different.

Since we have data which was generated using old namespace, I am unable to query this data with new data generated with new namespace.

Here is example of my schemas -

Old schema - "type" : "record", "name" : "Message", "namespace" : "com.myfirstavsc", "fields" : [ { "name" : "Header",.....**other fields**

New schema - "type" : "record", "name" : "Message", "namespace" : "com.mysecondavsc", "fields" : [ { "name" : "Header",.....**other fields**

When I query my hive table I get below exception

Failed with exception java.io.IOException:org.apache.avro.AvroTypeException: Found com.myfirstavsc.Property, expecting union
4

1 回答 1

1

我不确定您如何尝试读取数据,但使用 GenericDatumReader 应该可以解决您的问题,之后您可以将通用记录转换为您的特定记录。我在这里找到了类似的东西

http://apache-avro.679487.n3.nabble.com/Deserialize-with-different-schema-td4032782.html

于 2017-08-10T13:44:45.213 回答