0

I've registered the following Avro schema for a topic:

{
  "type": "array",
  "items": "com.example.User"
}

where com.example.User is of type record and is defined in a separate file.

I know that SpecificAvroSerde can be used to serialize/ deserialize a SpecificRecord, but what Serdes should you use for an array of records?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    SpecificRecord schema can be an array, AFAIK – OneCricketeer Nov 08 '20 at 18:28
  • Thank you for your reply. Might you be able to share some code to show me how to create a SpecificRecord with an array schema? I'm not quite sure what you mean. A SpecificRecord can have a *field* which is an array, but surely it can't be an array itself? –  Nov 08 '20 at 20:16
  • 1
    Well, I've never actually registered an array schema into the registry, only an object that holds a list of other record items. But still, `SpecificData` return a `List` class when the Schema is of type Array - https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java#L266 – OneCricketeer Nov 08 '20 at 21:26
  • 1
    Does this answer your question? [How to create schema containing list of objects using Avro?](https://stackoverflow.com/questions/25076786/how-to-create-schema-containing-list-of-objects-using-avro) – miguno Nov 09 '20 at 10:37
  • Thanks, I'd actualy already seen this. But I have registered an array type to a topic, not a record type *containing* an array field. So it's a little different. –  Nov 09 '20 at 10:48

0 Answers0