7

We are trying to find a way to serialize Thrift schema into Avro format.

The flow is as follows:

We have a project 'A' which uses Thrift. The output result object is a thrift based object.

We have project 'B' which uses Avro. We would like to read the project 'A' Thrift schema and produce compatible Avro schema for project 'B'.

We have tried using the ThriftData provided in Apache Avro to serialize the Thrift schema

Schema schema = thriftData.getSchema(XYZ.class);

The execution fails with the message

java.lang.RuntimeException: java.lang.ClassCastException: org.apache.thrift.meta_data.FieldValueMetaData cannot be cast to org.apache.thrift.meta_data.StructMetaData

Any help regarding this would be highly appreciated!

  • 2
    A full stacktrace and a minimal example for XYZ would greatly help. – Arvid Heise Dec 17 '19 at 06:53
  • @ArvidHeise the exception seems to occur [here](https://github.com/rdblue/avro-java/blob/master/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java#L256). amrutasaraf did you manually modify the Java generated class by Thrift? Maybe you changed the *type* field? Can you show us the *.thrift* file? – gthanop Dec 19 '19 at 18:15

1 Answers1

0

You might want to check valueMetaData property to check if it has a correct type.

yu.pitomets
  • 1,660
  • 2
  • 17
  • 44