You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Spencer Nelson <s...@spencerwnelson.com> on 2021/03/11 20:11:57 UTC

Do fully-qualified names imply creation of a namespace?

When a named type definition has no dots in its 'name' field, and has no
'namespace' field, then the namespace is "taken from the most tightly
enclosing schema or protocol." For example:

{
  "type": "record",
  "name": "X",
  "namespace": "org.foo",
  "fields": [
    {"type": {"type": "fixed", "size": 8, "name": "Y"}, "name": "field"}
  ]
}

It is clear here that the fixed field's fullname is "org.foo.Y".

But what about if there is no *explicit* enclosing namespace? For example:

{
  "type": "record",
  "name": "org.foo.X",
  "fields": [
    {"type": {"type": "fixed", "size": 8, "name": "Y"}, "name": "field"}
  ]
}

What is the fullname of the fixed field here? Is it "org.foo.Y", because
the record implicitly created a namespace by using a fully-qualified name?
Or is it "Y", because there is no enclosing namespace?

Similarly, what if there is an explicit enclosing namespace - but only
after going past a fully-named type?

{
  "type": "record",
  "name": "Z",
  "namespace": "com.bar",
  "fields": [
    {
      "type": {
          "type": "record",
          "name": "org.foo.X",
          "fields": [
            {"type": "fixed", "size": 8, "name": "Y"}, "name": "field"}
          ],
     "name": "field",
    }
}

What is the fullname of the fixed field? Is it "org.foo.Y" (because the
record implicitly creates a namespace) or is it "com.bar.Y" (because the
tightest enclosing namespace is "com.bar")?