Define Avro Schema with fixed values

911 Views Asked by At

I am trying to define an general Avro Schema for a type of message-data I am transporting across Kafka. Some example data could be like this:

    "REDHEAD  BIGBODY  SLIMLEGS  53"
    "BLUEHEAD NOBODY   NONE       7"

Which roughly translates to a format of

    {Name: Header, Range: [0:8], Type: String, Size: 9}
    {Name: Body, Range: [9:17], Type: String, Size: 9}
    {Name: Tail, Range: [18:27], Type: String, Size:10}
    {Name: Age, Range: [28:29], Type: Int, Size: 2}

I tried to come up with an Avro Schema for this format but can't figure out a way to properly set up the fields for the 'range' and 'size' properties. I could write a general schema for every field entry like (name:name type:string, name:range type:string, name:type type:string, name:size type:int) but It isn't really what I wanted. Is there a way to wrap up a schema so I can use it to cut the fields in my messages?

0

There are 0 best solutions below