title: Spark: RDD as a tuple with second element as list to string
body: <p>I have an RDD as a tuple where its key as an integer and value as List of integers:</p>
  
  <pre><code>myDataRdd: RDD[(Int, List[Int])]
  </code></pre>
  
  <p>Data contains userId, the list of items the user have bought.</p>
  
  <p>I want to convert this to string such that:</p>
  
  <pre><code>userId, Product1, Product2,...
  </code></pre>
  
  <p>I did the following: </p>
  
  <pre><code>val convertedRDD :RDD[String] = recs.map(x =&gt; x._1 + "," + x._2.mkString(","))
  </code></pre>
  
  <p>But when I look at the part files the structure was completely different, which was: </p>
  
  <pre><code>1901437510,
  1471516971,
  336924029,
  2105754029,
  1130205965,
  654671035,
  2096277932,
  341111432,
  1485082568,
  1977671938,
  149397938,
  1655827062,
  </code></pre>