Can anyone explain me this?
The flipside, however, is that for transformations that cannot be guaranteed to pro‐ duce a known partitioning, the output RDD will not have a partitioner set. For example, if you call map() on a hash-partitioned RDD of key/value pairs, the function passed to map() can in theory change the key of each element, so the result will not have a partitioner. Spark does not analyze your functions to check whether they retain the key. Instead, it provides two other operations, mapValues() and flatMap Values(), which guarantee that each tuple’s key remains the same.
Source Learning Spark by Matei Zaharia, Patrick Wendell, Andy Konwinski, Holden Karau.