Certified Associate Developer for Apache Spark Exam QuestionsBrowse all questions from this exam

Certified Associate Developer for Apache Spark Exam - Question 107


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()

Show Answer
Correct Answer: E

To cache a DataFrame in Spark's memory, you use the persist method with the StorageLevel.MEMORY_ONLY parameter. The persist method allows you to specify storage levels, whereas cache defaults to MEMORY_AND_DISK. Therefore, the correct code block to cache storesDF only in memory is storesDF.persist(StorageLevel.MEMORY_ONLY).count().

Discussion

1 comment
Sign in to comment
AhmadktOption: E
Nov 27, 2023

E: df.persist(StorageLevel.MEMORY_ONLY).count()