Hi!

I'm trying to define optional records via ["null",
<record_definition>]. However, my attempt below fails with:
  "org.apache.avro.AvroTypeException: Unknown union branch a"

(BTW, unions like ["null", "string"] work, but I don't know how to
define non-recursive complex types so I can refer to them briefly by
name like that.)



SCHEMA:
{ "type": "record",
  "name": "User",
  "fields" : [
    {"name": "username", "type": "string"},
    {"name": "x", "type": ["null",
                           {"type": "record",
                            "name": "Test",
                            "fields" : [
                              {"name": "a", "type": "int"}
                            ]}
                          ]}
  ]}

DATA:
{"username": "john", "x": {"a": 1}}
{"username": "ryan", "x": {"a": 1}}

COMMANDLINE:
java -jar avro-tools-1.5.4.jar fromjson --schema-file my-schema.schema
my-data.json -codec snappy > my-output.avro

JAVA VERSION:
"1.6.0_26"


Thanks for any help,
  Tj

Reply via email to