Hi,
I¹m trying to figure out how to make the location field in the following
schema a union of a record and null, similar to the way hometown is a union
of a string and null.
{
"name" : "Profile",
"type" : "record",
"fields" : [
{ "name" : "name", "type" : "string" },
{ "name" : "location", "type" : {
"type" : "record",
"name" :
"cityState",
"fields" : [
{
"name" : "city", "type" : [ "string" , "null" ] },
{
"name" : "state", "type" : [ "string", "null" ] }
]
}
},
{ "name" : "hometown", "type" : [ "string", "null" ] }
]
}
However, if I follow the pattern and make it:
{ "name" : "location", "type" : [ {
"type" : "record",
"name" :
"cityState",
"fields" : [
{
"name" : "city", "type" : [ "string" , "null" ] },
{
"name" : "state", "type" : [ "string", "null" ] }
]
}, ³null² ]
},
I get the following error
org.apache.avro.AvroRuntimeException: Not a record schema:
[{"type":"record","name":"cityState","namespace":"com.incentica.avro.profile
s","fields":[{"name":"city","type":["string","null"]},{"name":"state","type"
:["string","null"]}]},"null"].message}
>From what I read in the specification, this should be allowed. Is my syntax
incorrect?
Thanks.