1
votes

I'm new to Spark and transformation, so need a little help. I've managed to find reversed solution. when you make a value into a list and ot from. I want to "flatten" I guess the value of the key. I have a RDD like Map where Key is Int and value is List of Strings. I need to make pairs with Key and each Value in list into one RDD.

1

1 Answers

2
votes

You can use flatMap and then map each element to a tuple like so

val flattenedRDD = pairRDD.flatMap { case (i,l)  => l.map( l => (i,l)) }