HomeInterview QuestionsSpark, Stages, Data Processing

When you execute this notebook, how many stages will be created in the backend?

🟡 Medium Conceptual Mid level
25 Times asked
Aug 2026 Last seen
Aug 2026 First seen

💡 Model Answer

In Spark, a stage is a set of tasks that can run in parallel without shuffling data. The number of stages depends on the number of shuffle boundaries in the DAG. For a notebook that performs two transformations followed by an action, you typically get two stages: one for the transformations (no shuffle) and one for the action (which may trigger a shuffle if a reduceByKey or join is involved). If the notebook contains multiple actions or multiple shuffle operations, each shuffle introduces a new stage. Therefore, the exact count is determined by the logical plan, but you can inspect it with the Spark UI or the explain() method.

Sign in to unlock the rest of this answer

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