AVRO schema for JSON with mixed post types

I have the following problem for which I am kindly asking for advice. I have a JSON file where events of several types are mixed in one file. Each event is a line-structured record (no nesting). All events have an event identifier and type, and depending on the type of event, the structure of the fields in the event record is different. I need to make an AVRO schema file (.avsc) in order to convert the JSON file to the binary AVRO format. Given the JSON snippet as shown below, can you suggest me how to construct the corresponding AVRO schema please?

{"eventid":"EV1","eventtype":"A","timestamp": 1366150681, "fieldA1": 10, "fieldA2":"texta" }
{"eventid":"EV2","eventtype":"A","timestamp": 1366150699, "fieldA1": 11, "fieldA2":"atext" }
{"eventid":"EV3","eventtype":"B","timestamp": 1366150750, "fieldB1": "textb" }
{"eventid":"EV4","eventtype":"A","timestamp": 1366150821, "fieldA1": 9, "fieldA2":"texta" }
{"eventid":"EV5","eventtype":"C","timestamp": 1366150920, "fieldC1": 100, "fieldC2":200, "fieldC3":400 }
{"eventid":"EV6","eventtype":"C","timestamp": 1366150950, "fieldC1": 90, "fieldC2":150, "fieldC3":200 }
{"eventid":"EV7","eventtype":"B","timestamp": 1366150999, "fieldB1": "btext"}

      

etc.

Thank you in advance! I am waiting for your reply as soon as possible, please.

+3


source to share





All Articles