title: type mismatch in scala while using reduceByKey
body: <p>I have separately test my error code in scala shell</p>
  
  <pre><code>scala&gt; val p6 = sc.parallelize(List( ("a","b"),("b","c")))
  p6: org.apache.spark.rdd.RDD[(String, String)] = ParallelCollectionRDD[10] at parallelize at &lt;console&gt;:24
  
  scala&gt; val p7 = p6.map(a =&gt; ((a._1+a._2), (a._1, a._2, 1)))
  p7: org.apache.spark.rdd.RDD[(String, (String, String, Int))] = MapPartitionsRDD[11] at map at &lt;console&gt;:26
  
  scala&gt; val p8 = p7.reduceByKey( (a,b) =&gt; (a._1,(a._2, a._3+b._3)))
  &lt;console&gt;:28: error: type mismatch;
   found   : (String, (String, Int))
   required: (String, String, Int)
         val p8 = p7.reduceByKey( (a,b) =&gt; (a._1,(a._2, a._3+b._3)))
  </code></pre>
  
  <p>I want to use <code>a._1</code> as the key so that I can further use <code>join</code> operator, and it is required to be (key, value) pairs. But my question is, why there is a <code>required</code> type while I am using reducing function? I think the format is set by ourselves instead of something regulated. Am I wrong?</p>
  
  <p>Also, if I am wrong, then why it is <code>(String, String, Int)</code> required? Why it is not something else? </p>
  
  <p>ps: I know <code>(String, String, Int)</code> is the value type in <code>(a._1+a._2), (a._1, a._2, 1))</code> which is the map function, but the official example shows that the reduce funtion <code>(a, b) =&gt; (a._1 + b._1, a._2 + b._2)</code> is valid. And I think all of these including my code above should be valid</p>