Databricks Certified Associate Developer for Apache Spark — Question 191
Given the code fragment:
div_by_2 = my_df.filter(“number % 2 = 0”)
print (div_by_2)
The output ofthe code fragment is:
DataFrame[nunber: bigint]
What describes the output for this transformation on the Apache Spark engine?
Answer options
- A. The filter transformation triggers an immediate computation and action returning only rows that match the condition.
- B. All transformations in Spark are lazy, in that they do not compute her results right away.
- C. After each transformation in Spark the results are processed using an action.
- D. The filter is an action in Spark it immediately executes the filing operation on my_df and returns the results as div_by_2.
Correct answer: B
Explanation
The correct answer is B because Spark transformations, like filter, are lazily evaluated, meaning they do not execute until an action is called. Options A, C, and D incorrectly imply that the filter transformation triggers immediate execution, which contradicts Spark's lazy evaluation model.