You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Brennan Vincent <br...@umanwizard.com> on 2022/08/22 18:10:44 UTC

Impossible to refer to names in the default namespace from another namespace?

Hello,

https://github.com/apache/avro/pull/917 introduced the following language to the spec:

> The null namespace may not be used in a dot-separated sequence of names.

Thus ruling out fullnames like ".foo".

However, this seems to rule out referring to names in the default namespace from another namespace.

For example, this schema was previously allowed by the spec:

{
    "type": "record",
    "name": "r",
    "fields": [
        {
            "name": "f",
            "type": {
                "type": "record",
                "name": "r2",
                "namespace": "ns",
                "fields": [
                    {
                        "name": "f2",
                        "type": ["null", ".r"]
                    }
                ]
            }
        }
    ]
}

Note ".r" in the type of "f2". This can't be changed to "r",
because that would be interpreted as "ns.r" due to "ns" being the nearest
enclosing namespace.

Thus it seems that the new spec has restricted the set of valid schemas and there is no longer
any way to accomplish this.

Am I misinterpreting the spec? Does the empty namespace being disallowed in dotted sequences
of names only apply to initial name definitions, but not to later name references? Or is there
some other way to express this?

Here is the initial discussion of this change, where the issue I'm raising here doesn't
appear to have come up: https://lists.apache.org/thread/q0o58fxgvstvdlgpoyv2pcz53borp587

Thanks,

Re: Impossible to refer to names in the default namespace from another namespace?

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

I might be wrong but I think your sample schema should be valid! Does it
fail with any of the SDKs ?

This part of the spec talks about the namespace, not the type. I.e.
"namespace": ".ns" would be an error.

On Mon, Aug 22, 2022 at 10:40 PM Brennan Vincent <br...@umanwizard.com>
wrote:

> Hello,
>
> https://github.com/apache/avro/pull/917 introduced the following language
> to the spec:
>
> > The null namespace may not be used in a dot-separated sequence of names.
>
> Thus ruling out fullnames like ".foo".
>
> However, this seems to rule out referring to names in the default
> namespace from another namespace.
>
> For example, this schema was previously allowed by the spec:
>
> {
>     "type": "record",
>     "name": "r",
>     "fields": [
>         {
>             "name": "f",
>             "type": {
>                 "type": "record",
>                 "name": "r2",
>                 "namespace": "ns",
>                 "fields": [
>                     {
>                         "name": "f2",
>                         "type": ["null", ".r"]
>                     }
>                 ]
>             }
>         }
>     ]
> }
>
> Note ".r" in the type of "f2". This can't be changed to "r",
> because that would be interpreted as "ns.r" due to "ns" being the nearest
> enclosing namespace.
>
> Thus it seems that the new spec has restricted the set of valid schemas
> and there is no longer
> any way to accomplish this.
>
> Am I misinterpreting the spec? Does the empty namespace being disallowed
> in dotted sequences
> of names only apply to initial name definitions, but not to later name
> references? Or is there
> some other way to express this?
>
> Here is the initial discussion of this change, where the issue I'm raising
> here doesn't
> appear to have come up:
> https://lists.apache.org/thread/q0o58fxgvstvdlgpoyv2pcz53borp587
>
> Thanks,
>