Exam Certified Associate Developer for Apache Spark All QuestionsBrowse all questions from this 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()

    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
AhmadktOption: E

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