title: Spark - repartition() vs coalesce()
body: <p>According to Learning Spark</p>
  
  <blockquote>
    <p>Keep in mind that repartitioning your data is a fairly expensive operation.
    Spark also has an optimized version of <code>repartition()</code> called <code>coalesce()</code> that allows avoiding data movement, but only if you are decreasing the number of RDD partitions.</p>
  </blockquote>
  
  <p>One difference I get is that with <code>repartition()</code> the number of partitions can be increased/decreased, but with <code>coalesce()</code> the number of partitions can only be decreased.</p>
  
  <p>If the partitions are spread across multiple machines and <code>coalesce()</code> is run, how can it avoid data movement?</p>