Databricks Certified Associate Developer for Apache Spark — Question 38

The code block shown below contains an error. The code block is intended to return a new 12-partition DataFrame from the 8-partition DataFrame storesDF by inducing a shuffle. Identify the error.
Code block:
storesDF.coalesce(12)

Answer options

Correct answer: B

Explanation

The correct answer is B because the coalesce() operation is designed to reduce the number of partitions and does not induce a shuffle, making it unsuitable for increasing the number of partitions. Options A, C, D, and E are incorrect as they misrepresent the functionality of coalesce() regarding partitioning and shuffling.