title: Extract columns in nested Spark DataFrame as scala Arrays
body: <p>I have a DataFrame <code>myDf</code> which contains an array of pairs of points (i.e. x and y coordinates), it has the following schema:</p>
  
  <pre><code>myDf.printSchema
  
  root
   |-- pts: array (nullable = true)
   |    |-- element: struct (containsNull = true)
   |    |    |-- x: float (nullable = true)
   |    |    |-- y: float (nullable = true)
  </code></pre>
  
  <p>I want to get <code>x</code> and <code>y</code> as individual plain Scala <code>Array</code>'s. I think I need to apply the explode-function, but I cannot figure out how. I tried to apply <a href="https://stackoverflow.com/questions/37172254/select-specific-columns-in-spark-dataframes-from-array-of-struct">this</a> solution but I cant get it to work.</p>
  
  <p>I'm using Spark 1.6.1 with Scala 2.10</p>
  
  <p>EDIT: I realize that I had a misunderstanding how Spark works, getting the actual arrays is only possible if the data is collected (or using UDFs)</p>