Discussed in AVRO-248

Arguments in Favor

Proposal

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

Language APIs

For Java, code is generated for a union, a class could be generated that includes an enum indicating which branch of the union is taken, e.g., a union of string and int named Foo might cause a Java class like

      public class Foo {
        public static enum Type {STRING, INT};
        private Type type;
        private Object datum;
        public Type getType();
        public String getString() { if (type==STRING) return (String)datum; else throw ... }
        public void setString(String s) { type = STRING;  datum = s; }
        ....
      }

Then Java applications can easily use a switch statement to process union values rather than using instanceof.