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

Which of the following code blocks attempts to cache the partitions of DataFrame storesDF only in Spark’s memory?

    Correct Answer: D

    The correct way to cache the partitions of DataFrame storesDF only in Spark's memory is by using the persist method with the StorageLevel.MEMORY_ONLY storage level. Therefore, the correct code block is storesDF.persist(StorageLevel.MEMORY_ONLY).count(). This ensures that the DataFrame is persistently stored in memory distinctively without spilling to disk.

Discussion
Sowwy1Option: D

D. storesDF.persist(StorageLevel.MEMORY_ONLY).count()