in elitzur-avro/src/main/scala/com/spotify/elitzur/converters/avro/AvroConverter.scala [133:142]
override def toAvro(v: Option[T], schema: Schema): Any = {
v match {
case None => null
case Some(t) =>
schema.getTypes.asScala.toList.filterNot(_.getType == Schema.Type.NULL) match {
case head :: Nil => implicitly[AvroConverter[T]].toAvro(t, head)
case _ => throw new IllegalArgumentException("Option may only be UNION of two types")
}
}
}