title: How do I flatMap a row of arrays into multiple rows?
body: <p>After parsing some jsons I have a one-column DataFrame of arrays</p>
  
  <pre><code>scala&gt; val jj =sqlContext.jsonFile("/home/aahu/jj2.json")
  res68: org.apache.spark.sql.DataFrame = [r: array&lt;bigint&gt;]
  scala&gt; jj.first()
  res69: org.apache.spark.sql.Row = [List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)]
  </code></pre>
  
  <p>I'd like to explode each row out into several rows. How?</p>
  
  <p><strong>edit:</strong></p>
  
  <p>Original json file:</p>
  
  <pre><code>{"r": [0,1,2,3,4,5,6,7,8,9]}
  {"r": [0,1,2,3,4,5,6,7,8,9]}
  </code></pre>
  
  <p>I want an RDD or a DataFrame with 20 rows.</p>
  
  <p>I can't simply use flatMap here - I'm not sure what the appropriate command in spark is:</p>
  
  <pre><code>scala&gt; jj.flatMap(r =&gt; r)
  &lt;console&gt;:22: error: type mismatch;
   found   : org.apache.spark.sql.Row
   required: TraversableOnce[?]
                jj.flatMap(r =&gt; r)
  </code></pre>