Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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

Code Block
{
    "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.