QuestionQ281Verified/Developing Apache Spark™ DataFrame/DataSet API ApplicationsCopy linkReport a problemAsk AstroTutorSave questionHow do df.cache() and df.persist() differ for a Spark DataFrame?ABoth cache() and persist () can be used to set the default storage level (MEMORY_AND_DISK_DESER)BBoth functions perform the same operation. The persist () function provides improved performance as its default storage level is DISK_ONLY.Cpersist () – Persists the DataFrame with the default storage level (MEMORY_AND_DISK_DESER) and cache () – Can be used to set different storage levels to persist the contents of the DataFrame.Dcache() – Persists the DataFrame with the default storage level (MEMORY_AND_DISK_DESER) and persist () – Can be used to set different storage levels to persist the contents of the DataFrame.Show AnswerAnswerExplanationcache() persists a DataFrame using the default MEMORY_AND_DISK_DESER storage level. persist() also defaults to that level when called without an argument, but it accepts a StorageLevel argument, allowing the persistence level to be selected.Learn morepyspark.sql.DataFrame.cache — PySpark documentationpyspark.sql.DataFrame.persist — PySpark documentationShow comments0Show commentsCommunity DiscussionNo comments yet. Be the first to start the discussion!
Community Discussion