Databricks Certified Associate Developer for Apache Spark — Question 13

The code block shown below contains an error. The code block is intended to cache DataFrame storesDF only in Spark’s memory and then return the number of rows in the cached DataFrame. Identify the error.
Code block:
storesDF.cache().count()

Answer options

Correct answer: E

Explanation

The correct answer is E because the cache() method defaults to caching DataFrames at the MEMORY_AND_DISK level, which does not meet the requirement of caching only in memory. The other options incorrectly describe either the behavior of the cache() method or additional requirements that do not pertain to the error in the code block.