Question: what is the difference between map and flatmap and a good use case for each?
Answer: Map transforms an RDD of length N into another RDD of with the same length. The input and output RDDs typically may have the same number of records. A FlatMap function also takes one element as an input process according to the custom code (specified by the developer) and returns a 0 or more element at a time.