QuestionQ142

VerifiedTroubleshooting and Tuning Apache Spark DataFrame API Applications.

The code block below contains an error. It is intended to cache DataFrame storesDF only in Spark’s memory and then return the row count of the cached DataFrame. Identify the error.

storesDF.cache().count()  
Explanation

For a Spark DataFrame/Dataset, cache() uses the default MEMORY_AND_DISK storage level rather than a memory-only level, and it has no storage-level parameter. Memory-only persistence requires persist(MEMORY_ONLY), followed by count() to materialize the cached DataFrame.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!