Adding two columns to existing DataFrame using withColumn
<p>I have a <code>DataFrame</code> with a few columns. Now I want to add two more columns to the existing DataFrame.</p>

<p>Currently I am doing this using <code>withColumn</code> method in DataFrame.</p>

<p><strong>for example:</strong></p>

<pre><code>df.withColumn("newColumn1", udf(col("somecolumn")))
  .withColumn("newColumn2", udf(col("somecolumn")))
</code></pre>

<p>Actually I can return both newcoOlumn values in single UDF method using Array[String]. But currently this is how I am doing it.</p>

<p>Is there anyway, I can do this effectively? using <code>explode</code> is the good option here?</p>

<p>Even if I have to use <code>explode</code>,  I have to use <code>withColumn</code> once, then return the column value as <code>Array[String]</code>, then using <code>explode</code>, create two more columns.</p>

<p>Which one is effective? or is there any alternatives?</p>