Just to double check…. Your User class is autogenerated from the Schema by avro tools, right?
java -jar /path/to/avro-tools-1.8.2.jar compile schema user.avsc . It is not your own POJO class? -Mika On 19 Dec 2018, 0.01 +0200, [email protected], wrote: > > For union types (e.g bar in your schema) the first type is the default > > value. In case of a missing value (new User(null)) the reader expects to > > read a variable of default value type. Which in your example is a String. > > I don't think that was a the problem. As far as I can see, if I vary the > order of the "null" and "string", the binary output does not change (aside > from the schema header). > > This looks to be a problem between the "expected" versus the "actual" schema. > The actual schema is read correctly but unfortunately the "expected" schema > is what is calculated from my User class without the "null" field. The schema > from file is ignored? Grumble. > > So I guess I need to do something like: > > ReflectDataumReder<User> datumReader = new ReflectDatumReader<>(User.class); > datumReader.setExpected(schema); > DataFileReader<Schema> reader = ... > > Is that right? That just seems crazy. What am I doing wrong? > > Thanks, > gray > > > ---------- > This message was sent from a MailNull anti-spam account. You can get > your free account and take control over your email by visiting the > following URL. > > http://mailnull.com/
