I have a avro schema as below:
{
"name": "track",
"namespace": "com.company",
"type": "record",
"fields": [
{
"default": null,
"doc": "The user anonymous Id",
"name": "anonymous_id",
"type": [
"null",
"string"
]
},
"default": null,
"name": "properties",
"type": [
"null",
{
"fields": [
{
"aliases": [
"accountType"
],
"default": null,
"name": "account_type",
"type": [
"null",
"string"
]
}
],
"name": "properties",
"type": "record"
}
]
}
]
}
and for above avro I have case class defined as below.
case class Track(
anonymous_id: Option[String],
properties: Option[Properties]
)
case class Properties(account_type: Option[String])
and when I am deserialising the avro as below:
val trackData = AvroInputStream.binary[Track](eventValue, schema)
it is throwing the below error:
org.apache.avro.AvroTypeException: Found com.company.properties, expecting union
I have tried with Either data type but it is throwing the same error! Not sure what union here means in terms of Scala case class.
looks like problem with namespaces in nested schemas. Here is ticket (for Hive but that good man is claiming it is Avro bug) https://issues.apache.org/jira/browse/HIVE-15316. I'm working on it too, and going to add namespaces in nested schemas.