You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Askar Safin <sa...@mail.ru> on 2021/12/27 16:42:50 UTC

Spec wording on fullnames is not clear

Hi. I'm writing Avro implementation in Rust for personal use. I have a question. Consider this Avro scheme:

{
  "type": "record",
  "name": "a.b",
  "fields": [
    {
      "name": "c",
      "type": {
        "type": "record",
        "name": "d",
        "fields": []
      }
    }
  ]
}

What is fullname of record "c"? "a.c" or "c"? I think Avro specification is vague about this and should be fixed. When I attempt to interpret Avro spec literally, I get to conclusion that the fullname is "a.c". But this contradicts to my common sense.

==
Askar Safin
http://safinaskar.com
https://sr.ht/~safinaskar
https://github.com/safinaskar

Re: Spec wording on fullnames is not clear

Posted by Oscar Westra van Holthe - Kind <os...@westravanholthe.nl>.
On Mon 27 dec. 2021 17:42, Askar Safin <sa...@mail.ru> wrote:

> Hi. I'm writing Avro implementation in Rust for personal use. I have a
> question. Consider this Avro scheme:
>
> {
>   "type": "record",
>   "name": "a.b",
>   "fields": [
>     {
>       "name": "c",
>       "type": {
>         "type": "record",
>         "name": "d",
>         "fields": []
>       }
>     }
>   ]
> }
>
> What is fullname of record "c"? "a.c" or "c"? I think Avro specification
> is vague about this and should be fixed. When I attempt to interpret Avro
> spec literally, I get to conclusion that the fullname is "a.c". But this
> contradicts to my common sense.
>

c is a field in record a.d: d has no namespace and a simple name (without a
dot), so the namespace is taken from the innermost enclosing named type
(b), which has namespace a

Kind regards,
Oscar

Re: Spec wording on fullnames is not clear

Posted by Brennan Vincent <br...@umanwizard.com>.
Right, sorry, indeed -- `c` is a field name.

The type fullname would be a.d in the example you showed.

The spec says (in a list of the possible ways full names can be determined):

A name only is specified, i.e., a name that contains no dots. In this case the namespace is taken from the most tightly enclosing schema or protocol. For example, if "name": "X" is specified, and this occurs within a field of the record definition of org.foo.Y, then the fullname is org.foo.X. If there is no enclosing namespace then the null namespace is used.
IMO, the spec is clear that there is no difference between specifying a namespace separately (e.g. "namespace": "a", "name": "b"), and specifying a namespace implicitly (e.g. "name": "a.b").

> On Dec 27, 2021, at 1:25 PM, Spencer Nelson <s...@spencerwnelson.com> wrote:
> 
> Trick question! "c" is a field name, not a type name, so the fullname is either "a.d" or "d". Fields don't have fullnames.
> 
> But your question is still good. I don't think this is clear in the Avro specification either. I asked avro-dev about this about a year ago and got no response: http://mail-archives.us.apache.org/mod_mbox/avro-dev/202103.mbox/%3cCAB6dobWX1=_FcTGvgM-d5r17PV_69u27TDZvLJMWc+aizowDiw@mail.gmail.com%3e <http://mail-archives.us.apache.org/mod_mbox/avro-dev/202103.mbox/%3cCAB6dobWX1=_FcTGvgM-d5r17PV_69u27TDZvLJMWc+aizowDiw@mail.gmail.com%3e>
> 
> As I mentioned in that email, there are even more tricky cases than the one you listed. What if the "a.b" schema definition is wrapped inside another schema with an explicit "namespace" field? Like this:
> 
> {
>   "type": "record",
>   "name": "wrapper",
>   "namespace": "wrapping"
>   "fields": [
>     {
>       "name": "inside",
>       "type": {
>           "type": "record",
>           "name": "a.b",
>         "fields": [
>           {
>             "name": "c",
>             "type": {
>               "type": "record",
>               "name": "d",
>               "fields": []
>             }
>           }
>         ]
>       }
>     }
>   ]
> }
> 
> Now is the interior one "a.d" (since "a.b" is a fullname, so it implicitly creates a namespace of "a"), or is it "wrapping.d" (since that's the first explicit namespace)?
> 
> The spec just says that when a type is named with dots in it (like "a.b"), then it ignores any namespaces, but it doesn't say it creates one for all children. I think implementations are inconsistent in how they handle this, and it needs to be cleaned up in the spec.
> 
> 
> 
> On Mon, Dec 27, 2021 at 1:53 PM Brennan Vincent <brennan@umanwizard.com <ma...@umanwizard.com>> wrote:
> It is a.c
> 
> > On Dec 27, 2021, at 9:42 AM, Askar Safin <safinaskar@mail.ru <ma...@mail.ru>> wrote:
> > 
> > Hi. I'm writing Avro implementation in Rust for personal use. I have a question. Consider this Avro scheme:
> > 
> > {
> >  "type": "record",
> >  "name": "a.b",
> >  "fields": [
> >    {
> >      "name": "c",
> >      "type": {
> >        "type": "record",
> >        "name": "d",
> >        "fields": []
> >      }
> >    }
> >  ]
> > }
> > 
> > What is fullname of record "c"? "a.c" or "c"? I think Avro specification is vague about this and should be fixed. When I attempt to interpret Avro spec literally, I get to conclusion that the fullname is "a.c". But this contradicts to my common sense.
> > 
> > ==
> > Askar Safin
> > http://safinaskar.com <http://safinaskar.com/>
> > https://sr.ht/~safinaskar <https://sr.ht/~safinaskar>
> > https://github.com/ <https://github.com/>


Re[2]: Spec wording on fullnames is not clear

Posted by Askar Safin <sa...@mail.ru>.
> Trick question! "c" is a  field name , not a type name, so the fullnameĀ is
> either "a.d" or "d". Fields don't have fullnames.
Oops. Of course I meant this:
>What is fullname of record "d"? "a.d" or "d"? I think Avro specification is vague about this and should be fixed. When I attempt to interpret Avro spec literally, I get to conclusion that the fullname is "a.d". But this contradicts to my common sense.

==
Askar Safin
http://safinaskar.com
https://sr.ht/~safinaskar
https://github.com/safinaskar

Re: Spec wording on fullnames is not clear

Posted by Spencer Nelson <s...@spencerwnelson.com>.
Trick question! "c" is a *field name*, not a type name, so the fullname is
either "a.d" or "d". Fields don't have fullnames.

But your question is still good. I don't think this is clear in the Avro
specification either. I asked avro-dev about this about a year ago and got
no response:
http://mail-archives.us.apache.org/mod_mbox/avro-dev/202103.mbox/%3cCAB6dobWX1=_FcTGvgM-d5r17PV_69u27TDZvLJMWc+aizowDiw@mail.gmail.com%3e

As I mentioned in that email, there are even more tricky cases than the one
you listed. What if the "a.b" schema definition is wrapped inside another
schema with an explicit "namespace" field? Like this:

{
  "type": "record",
  "name": "wrapper",
  "namespace": "wrapping"
  "fields": [
    {
      "name": "inside",
      "type": {
          "type": "record",
          "name": "a.b",
        "fields": [
          {
            "name": "c",
            "type": {
              "type": "record",
              "name": "d",
              "fields": []
            }
          }
        ]
      }
    }
  ]
}

Now is the interior one "a.d" (since "a.b" is a fullname, so it implicitly
creates a namespace of "a"), or is it "wrapping.d" (since that's the first
explicit namespace)?

The spec just says that when a type is named with dots in it (like "a.b"),
then it ignores any namespaces, but it doesn't say it creates one for all
children. I think implementations are inconsistent in how they handle this,
and it needs to be cleaned up in the spec.



On Mon, Dec 27, 2021 at 1:53 PM Brennan Vincent <br...@umanwizard.com>
wrote:

> It is a.c
>
> > On Dec 27, 2021, at 9:42 AM, Askar Safin <sa...@mail.ru> wrote:
> >
> > Hi. I'm writing Avro implementation in Rust for personal use. I have a
> question. Consider this Avro scheme:
> >
> > {
> >  "type": "record",
> >  "name": "a.b",
> >  "fields": [
> >    {
> >      "name": "c",
> >      "type": {
> >        "type": "record",
> >        "name": "d",
> >        "fields": []
> >      }
> >    }
> >  ]
> > }
> >
> > What is fullname of record "c"? "a.c" or "c"? I think Avro specification
> is vague about this and should be fixed. When I attempt to interpret Avro
> spec literally, I get to conclusion that the fullname is "a.c". But this
> contradicts to my common sense.
> >
> > ==
> > Askar Safin
> > http://safinaskar.com
> > https://sr.ht/~safinaskar
> > https://github.com/
>

Re: Spec wording on fullnames is not clear

Posted by Brennan Vincent <br...@umanwizard.com>.
It is a.c

> On Dec 27, 2021, at 9:42 AM, Askar Safin <sa...@mail.ru> wrote:
> 
> Hi. I'm writing Avro implementation in Rust for personal use. I have a question. Consider this Avro scheme:
> 
> {
>  "type": "record",
>  "name": "a.b",
>  "fields": [
>    {
>      "name": "c",
>      "type": {
>        "type": "record",
>        "name": "d",
>        "fields": []
>      }
>    }
>  ]
> }
> 
> What is fullname of record "c"? "a.c" or "c"? I think Avro specification is vague about this and should be fixed. When I attempt to interpret Avro spec literally, I get to conclusion that the fullname is "a.c". But this contradicts to my common sense.
> 
> ==
> Askar Safin
> http://safinaskar.com
> https://sr.ht/~safinaskar
> https://github.com/