title: How to create a Row from a given case class?
body: <p>Imagine that you have the following case classes:</p>
  
  <pre><code>case class B(key: String, value: Int)
  case class A(name: String, data: B)
  </code></pre>
  
  <p>Given an instance of <code>A</code>, how do I create a Spark <code>Row</code>? e.g.</p>
  
  <pre><code>val a = A("a", B("b", 0))
  val row = ???
  </code></pre>
  
  <p>NOTE: Given <code>row</code> I need to be able to get data with: </p>
  
  <pre><code>val name: String = row.getAs[String]("name")
  val b: Row = row.getAs[Row]("data")
  </code></pre>