Databricks Certified Associate Developer for Apache Spark — Question 87
The code block shown below should cache DataFrame storesDF only in Spark's memory. Choose the response that correctly fil ls in the numbered blanks within the code block to complete this task.
Code block:
__1__.__2__(__3__).count()
Answer options
- A. 1. storesDF 2. cache 3. StorageLevel.MEMORY_ONLY
- B. 1. storesDF 2. storageLevel 3. cache
- C. 1. storesDF 2. cache 3. Nothing
- D. 1. storesDF 2. persist 3. Nothing
- E. 1. storesDF 2. persist 3. StorageLevel.MEMORY_ONLY
Correct answer: E
Explanation
The correct answer is E because using 'persist' with 'StorageLevel.MEMORY_ONLY' specifically instructs Spark to cache the DataFrame in memory only. Option A is incorrect because 'cache' is not used with a storage level. Options B, C, and D do not specify the appropriate storage level or use the correct caching method.