Recall & Review
beginner
What does the map operation do in Apache Spark?
The map operation applies a function to each element of an RDD or DataFrame column and returns a new RDD or column with the transformed elements.
Click to reveal answer
beginner
Explain the purpose of the filter operation in Spark.
The filter operation selects elements from an RDD or DataFrame column that satisfy a given condition, removing all others.
Click to reveal answer
intermediate
What is the difference between map and flatMap in Spark?
map transforms each element into exactly one element, while flatMap can transform each element into zero or more elements, flattening the results into a single list.
Click to reveal answer
beginner
Give a real-life example of using filter in data processing.
Filtering a list of customer orders to keep only those with an amount greater than $100 is a real-life example of using filter.
Click to reveal answer
intermediate
Why is flatMap useful when working with text data in Spark?
flatMap is useful for splitting lines of text into words because it can turn one line into many words, flattening them into a single list for easier processing.
Click to reveal answer
What does the map operation return when applied to an RDD?
✗ Incorrect
map applies a function to each element and returns a new RDD with transformed elements.
Which operation would you use to keep only even numbers from an RDD?
✗ Incorrect
filter selects elements that meet a condition, such as being even.
What is the key feature of flatMap compared to map?
✗ Incorrect
flatMap can return multiple elements per input, flattening the results.
If you want to split sentences into words in Spark, which operation is best?
✗ Incorrect
flatMap splits each sentence into multiple words and flattens them.
Which operation removes elements from an RDD?
✗ Incorrect
filter removes elements that do not meet the condition.
Describe how you would use map, filter, and flatMap to process a list of sentences to get all words longer than 3 letters.
Think about splitting, selecting, and transforming steps.
You got /3 concepts.
Explain the difference between map and flatMap with an example.
Focus on output size per input element.
You got /3 concepts.