I'm using jackson-avro to generate schema for my POJO. The POJO has this field:
List<List<Object>> data
This is basically how the data form the database is returned, the above nested List represents the table result. Looks like Jackson has no way of converting the Object type to an Avro type, probably because Avro has no native type to support Object.
I was thinking I could extend the jackson library to handle the Object type as:
{"name":"data","type":[{"type":"array","items":{"type":"array","items":["string","int","long","float","double","boolean","null"]}},"null"]}
I'm saying that if the data type is Object, then the Avro type should be:
["string","int","long","float","double","boolean","null"]}},"null"]
Is there a way to do that easily? Or are there any other ways of handling Object data type with Avro?
Update:
- Yes, the metadata is passed separately as a List, that inlcudes the column, position, and datatype
- The
List<List<Object>>
can be a table that has columns with datatype that are string(varchar), boolean, number(int, long,double, BigDecimal) - I need a schema because I need to send this over the network in avro format
- Or perhaps I could update it to
List<List<String>>
and then have the client cast it as per the metadata, I guess? i tried it and it works, not sure if it changes the client side - Currently when jackson tries to get the schema for Object, it generates:
{"type":"record","name":"Object","namespace":"java.lang","fields":[]}