title: Efficient way to return Array[String] from a spark dataframe without using collect()
body: <p>I want to return <code>child</code> as an <code>Array[String]</code> from the below dataframe</p>
  <pre><code>root
       |-- parent: string (nullable = false)
       |-- child: array (nullable = true)
       |    |-- element: string (containsNull = true)
  </code></pre>
  <p>I am doing this currently which does work for less data</p>
  <pre><code>df.collect().flatMap(x =&gt; x.getAs[Seq[String]](&quot;child&quot;)).mkString(&quot;,&quot;)
  </code></pre>
  <p>but there are is a lot of data and spark driver is running <code>Out Of Memory</code> as <code>collect()</code> is known to do that.</p>
  <p>What is efficient way to return array of Strings from the above dataframe?</p>