Child pages
  • AEP 103 - Named Branches
Skip to end of metadata
Go to start of metadata

Discussed in AVRO-248

Arguments in Favor

  • Anonymous branches are not supported in some languages and require casts or type checks in others
  • One argument against named branches was that anonymous branches are a good way of handling nullable fields which could be handled as optionals (above)
  • Other serialization systems support names for unions and branches, arrays

Proposal

{
    "type": "union",
    "name": "Foo",
    "branches": [
        {"name": "URL", "type": "string"},
        {"name": "hostname", "type": "string"},
        ...
    ]
}

Language APIs

The language API should produce named typed accessors in addition to the tag. Languages which have native support for named branches e.g. C, C++, Pascal etc. should use an explicit tag and their native unions.

  • No labels