A quick question: If the datum is valid in more than one schema, what is
the scenario where knowing the specific schema is necessary? Is it that the
equivalent schemas might evolve in a divergent manner over time or perhaps
that by targeting a specific schema you are wanting to convey some out of
band information that may have some meaning to a consumer, if not Avro?

Elliot.

On 25 April 2018 at 12:27, Marcelo Valle <mvall...@gmail.com> wrote:

> I am writing a python program using the official avro library for python,
> version 1.8.2.
>
> This is a simple schema to show my problem:
>
>     {
>       "type": "record",
>       "namespace": "com.example",
>       "name": "NameUnion",
>       "fields": [
>         {
>           "name": "name",
>           "type": [
>             {
>               "type": "record",
>               "namespace": "com.example",
>               "name": "FullName",
>               "fields": [
>                 {
>                   "name": "first",
>                   "type": "string"
>                 },
>                 {
>                   "name": "last",
>                   "type": "string"
>                 }
>               ]
>             },
>             {
>               "type": "record",
>               "namespace": "com.example",
>               "name": "ConcatenatedFullName",
>               "fields": [
>                 {
>                   "name": "entireName",
>                   "type": "string"
>                 }
>               ]
>             }
>           ]
>         }
>       ]
>     }
>
> Possible datums for this schema would be `{"name": {"first": "Hakuna",
> "last": "Matata"}}` and `{"name": {"entireName": "Hakuna Matata"}}`.
>
> However, this gives margin to ambiguity, as not always avro will be able
> to detect the right schema specified in the union. In this case, either
> datum will correspond to 1 and only 1 valid schema, but there might be a
> case where more than 1 schema in the union would be valid.
>
> I wonder whether it would be possible to use a datum like `{"name":
> {"FullName": {"first": "Hakuna", "last": "Matata"}}}`, where the specific
> union schema name is specified in the datum.
>
> Is it possible? How to do it?
>
> --
> Marcelo Valle
> http://mvalle.com - @mvallebr
>

Reply via email to