title: How to efficiently find distinct values from each column in Spark
body: <p>To find distinct values from each column of an <code>Array</code> I tried</p>
  
  <pre><code>RDD[Array[String]].map(_.map(Set(_))).reduce { 
  (a, b) =&gt; (a.zip(b)).map { case (x, y) =&gt; x ++ y}}
  </code></pre>
  
  <p>which executes successfully. However, I'd like to know if there was a more efficient way of doing this than my sample code above. Thank you.</p>