Can we have duplicate fields in Avro?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can we have duplicate fields in Avro?

kant kodali
Hi All,

I was wondering if we can have duplicate fields in Avro? for example, If I have the following JSON {"city": "Toronto", "city": "Newyork"} and try to grab the key "city" I believe the JSON parser either throws error or returns "Newyork" but I don't think it will give me both "Toronto" and "Newyork" so I am wondering if this limitation is same in Avro or is Avro ok with duplicate fields? 

And yes I can express city as an array or whatever but thats not what I want There are cases for me where I really want to use the same key (may be something similar to protobuf repeated).

Thanks! 
Reply | Threaded
Open this post in threaded view
|

Re: Can we have duplicate fields in Avro?

Mark Grey
Protobuf repeated still produces a List<T> in it's generated Java companion class.  I'm not aware of any way of representing this in either avro or pbuf that wouldn't require you to iterate through some sequence stored at that key.

On Sun, Jul 23, 2017 at 5:29 AM, kant kodali <[hidden email]> wrote:
Hi All,

I was wondering if we can have duplicate fields in Avro? for example, If I have the following JSON {"city": "Toronto", "city": "Newyork"} and try to grab the key "city" I believe the JSON parser either throws error or returns "Newyork" but I don't think it will give me both "Toronto" and "Newyork" so I am wondering if this limitation is same in Avro or is Avro ok with duplicate fields? 

And yes I can express city as an array or whatever but thats not what I want There are cases for me where I really want to use the same key (may be something similar to protobuf repeated).

Thanks!