Here at 51zero, we frequently use Avro as the format when interacting with Parquet based Hive stores. However using the Java API when dealing with types in Scala can be an exercise in tedium - having to write manual conversions to and from the GenericRecord type that underpins Avro.

So we’ve developed a conversion library, that allows boilerplate free conversions between scala case classes and avro schemas and avro records. Even better, the conversions don’t rely on runtime reflection, which is how the Java “conversions” take place, and instead use compile time macros, which means you’re getting no speed penalty from the use of such conversions.

(You’ll need to the import the various classes referenced in this article, but we won’t include those in the code snippets for brevity)

Let start by defining some case classes that we’ll convert.