title: What is the Difference between mapPartitions and foreachPartition in Apache Spark
body: <p>I have a DataFrame and in that one column is has comma separated data.</p>
  
  <p>For Example : Data looks like this :
  [{value:1}, {value:2, value:3}, {some value}, {somevalue, othervalue}]</p>
  
  <p>The column is of String datatype. I want to convert it to List and apply some function.
  Now i have a function for doing the conversion of the String column to List &amp; other applied logic. </p>
  
  <p>But which function will be better &amp; optimized as we have 2 similar sounding functions <strong>mapPartitions</strong> &amp; <strong>foreachPartitions</strong>, Does it have exact same performance &amp; in which one to use in what scenario ??</p>