Reputation: 30819
Here's Java equivalent of what I am trying to write a schema for, in Avro:
abstract class Vehicle {}
class Bike extends Vehicle {}
class Car extends Vehicle {}
class Bus extends Vehicle {}
Now, I want to have a file with List
of Vehicles, e.g.:
List<Vehicle> vehicles = ;
Elements in the list can be either of Bike, Car or Bus. Now, comparing this to Avro schema, I can see the Array type so I might have to write something like this (sorry for the hopelessness on the Avro part, I haven't worked with it before):
{
"name" : "vehicles",
"type" : "array",
"items" : {
"name" : "???"
}
}
This is as far as I could go, is there any way to specify that the items can be one of Bike, Car or Bus?
Upvotes: 0
Views: 658
Reputation: 41
Have you tried using union in items as
"items":["Bike","Car","Bus"]
Upvotes: 1