In case this helps anyone, I created a simple class to do the join and it works nicely for my use case. If there's already a library function for this, let me know.
Example ( https://github.com/Quantiply/rico/blob/master/avro-serde/src/test/java/com/quantiply/avro/JoinTest.java#L44-L52 ): GenericRecord in1 = getIn1(); GenericRecord in2 = getIn2(); GenericRecord joined = new Join(getJoinedSchema()) .merge(in1) .merge(in2) .getBuilder() .set("charlie", "blah blah") .build(); Class is here: https://github.com/Quantiply/rico/blob/master/avro-serde/src/main/java/com/quantiply/avro/Join.java Cheers, Roger On Thu, Apr 9, 2015 at 8:29 AM, Roger Hoover <roger.hoo...@gmail.com> wrote: > Hi, > > If I have a two records of type A and B as below and want to join them > similar to "SELECT *" in SQL to produce a record of type AB, is there an > simple way to do this with Avro without writing code to copy each field > individually? It's like a reverse projection. I want to take to disjoint > projections of AB and merge them to create an AB record. > > I appreciate any help. > > Thanks, > > Roger > > { > "name": "A", > "type": "record", > "namespace": "fubar", > "fields": [{"name": "a", "type" : "int"}] > } > > { > "name": "B", > "type": "record", > "namespace": "fubar", > "fields": [{"name": "b", "type" : "int"}] > } > > { > "name": "AB", > "type": "record", > "namespace": "fubar", > "fields": [{"name": "a", "type" : "int"}, {"name": "b", "type" : "int"}] > } >