title: Which function in spark is used to combine two RDDs by keys
body: <p>Let us say I have the following two RDDs, with the following key-pair values.</p>
  
  <pre class="lang-py prettyprint-override"><code>rdd1 = [ (key1, [value1, value2]), (key2, [value3, value4]) ]
  </code></pre>
  
  <p>and </p>
  
  <pre class="lang-py prettyprint-override"><code>rdd2 = [ (key1, [value5, value6]), (key2, [value7]) ]
  </code></pre>
  
  <p>Now, I want to join them by key values, so for example I want to return the following</p>
  
  <pre class="lang-py prettyprint-override"><code>ret = [ (key1, [value1, value2, value5, value6]), (key2, [value3, value4, value7]) ] 
  </code></pre>
  
  <p>How I can I do this, in spark using Python or Scala? One way is to use join, but join would create a tuple inside the tuple. But I want to only have one tuple per key value pair.</p>