title: How to zip an RDD with its corresponding elements in another RDD?
body: <p>I have 2 RDD(s). Like this:</p>
  
  <p><strong>RDD1</strong></p>
  
  <pre><code>scala&gt; val rdd1 = spark.sparkContext.parallelize(List(1,1,2,3,4,4))
  rdd1: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[101] at parallelize at &lt;console&gt;:23
  </code></pre>
  
  <p>It contains repeated values.</p>
  
  <p><strong>RDD2</strong></p>
  
  <pre><code>scala&gt; val rdd2 = spark.sparkContext.parallelize(List(1,2,3,4))
  rdd2: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[102] at parallelize at &lt;console&gt;:23
  </code></pre>
  
  <p>It contains all unique values that are present in <strong>RDD1</strong>.</p>
  
  <p>Now, I am applying zip over <strong>RDD1</strong> and <strong>RDD2</strong> like this:</p>
  
  <pre><code>scala&gt; rdd1.distinct.coalesce(rdd2.getNumPartitions).zip(rdd2).collect
  res22: Array[(Int, Int)] = Array((4,1), (1,2), (2,3), (3,4))
  </code></pre>
  
  <p>Here it is zipping <code>4</code> with <code>1</code>, <code>2</code> with <code>3</code> and so on. Whereas I want result in following format:</p>
  
  <pre><code>Array((1,1), (2,2), (3,3), (4,4))
  </code></pre>
  
  <p>How should I apply zip operation on them so that I can achieve expected output ?</p>