Hi Ben,
No worries, I was out on vacation all last week anyway.
For the 8 fields, as far as I can tell, in the AvroSchema.scala code the largest number of fields that can be handled is in Tuple8Schema which reads in a GenericData.Record, gets the first 8 fields and then outputs a Tuple of those fields. My use case is generally reading in records with more than 8 fields and often using the schema to do some projection and only get the fields I want. Both of these capabilities would be nice to have and it would be simple to extend the number of fields handled but at some point we also bump into the max size for a tuple too.
Similarly for the output I would like to have some finer control (be able to name fields and add other info) over what the output record looks like. Having the schema in hand helps here as well.
I agree the best solution would be use the existing AvroSchema code but as you noticed I wasn't sure how to set the schema without taking it in explicitly. Something like the below would be nice but I don't see a good way to populate the schema:
implicit def GenericDataRecordSchema = new AvroSchema[GenericData.Record] {
type AvroType = GenericData.Record
val schema: Schema = ???
def fromAvro(x: GenericData.Record): GenericData.Record = x
def toAvro(x: GenericData.Record): GenericData.Record = x
}
If you (or anyone else) sees a nice way to do this I think most things would be solved immediately.
If that's not possible then overloading the current fromAvroFile/toAvroFile would be fine with me. I mainly broke them into different methods for ease of reading.
I think also with the newest version of Avro I can use SpecificData instead and it will fall back on GenericData when it needs to. I'll look into that since it would save having multiple methods.
Thanks for the help,
Chris