HomeInterview QuestionsIn Spark, operations are either actions or transfo…

In Spark, operations are either actions or transformations. How would you categorize caching and persistence? Would you consider them actions or transformations?

🟡 Medium Conceptual Junior level
1Times asked
Aug 2026Last seen
Aug 2026First seen

💡 Model Answer

In Spark, cache() and persist() are lazy transformations that mark an RDD or DataFrame to be stored in memory or on disk with a specified storage level. They do not trigger a job by themselves; the actual caching occurs when an action forces evaluation of the RDD. Because they are applied to an RDD and return a new RDD with a persistence flag, they are classified as transformations. They are useful for speeding up subsequent actions that reuse the same data, but they do not produce output like actions do.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500