Spark "replacing null with 0" performance comparison
<p>Spark 1.6.1, Scala api.</p>

<p>For a dataframe, I need to replace all null value of a certain column with 0.
I have 2 ways to do this.
1.</p>

<pre><code>myDF.withColumn("pipConfidence", when($"mycol".isNull, 0).otherwise($"mycol"))
</code></pre>

<p>2.</p>

<pre><code>myDF.na.fill(0, Seq("mycol"))
</code></pre>

<p>Are they essentially the same or one way is preferred?</p>

<p>Thank you!</p>