Hi,
In the avro spec it has the following example:
{
"type": "record",
"name": "longlist",
"fields" : {
"value" : "long",
"next" : ["longlist", "null"]
}
}
Here longlist appears as a type in the union "next."
I'm wondering if anyone can fill me in on the rules for referring to
record names as types?
Is the scope of the record only for the current record?
Or, for example, if I had an record that defined 2 fields, each a
record, could record 2 refer to record 1 by name? And vise-versa (i.e.
can we forward reference types not yet defined)?
{
"type": "record",
"name": "longlist",
"fields" : {
"nested1" : {
"type" : "record",
"name" : "rec1",
"fields" : {
"a":"long",
"b": "rec2" /* LEGAL? to refer to rec2? */
}
}
}
"nested2" : {
"type" : "record",
"name" : "rec2",
"fields" : {
"c":"long",
"d": "rec1" /* LEGAL? to refer to rec1? */
}
}
"contrived" : ["longlist", "rec1", "rec2"] /* LEGAL? */
}
}
Also, can named fields also be referred to as types in other fields?
{
"type": "record",
"name": "longlist",
"fields" : {
"value" : "long",
"next" : ["longlist", "null"],
"likenext" : "next" /* LEGAL? to refer to next as type? */
}
}
thanks,
Scott