PySpark12 min read

Spark Transformations & Actions Interview Questions

Master Spark Transformations and Actions with topic-wise interview questions covering lazy evaluation, execution flow, narrow vs wide transformations, lineage, DAG, production scenarios, and interview tips.

2026-06-25

Part of Series

Spark Interview Preparation

Progress

8/8

← Previous Article

Spark Window Functions Interview Questions

Current Article

Spark Transformations & Actions Interview Questions

Part 8

Spark Transformations & Actions Interview Questions

Spark Transformations and Actions are the foundation of every Spark application. Whether you're processing millions of records or building enterprise-scale ETL pipelines, every Spark job is a combination of transformations and actions.

Although these concepts appear simple, they are among the most frequently asked topics in Spark interviews because they explain how Spark executes code internally.

Interviewers often ask questions such as:

  • What is the difference between a Transformation and an Action?
  • What is Lazy Evaluation?
  • Why doesn't Spark execute transformations immediately?
  • What is a Narrow Transformation?
  • What is a Wide Transformation?
  • What happens internally when an Action is triggered?
  • How does Spark create a DAG?

This guide is designed as a quick interview revision resource.

Instead of lengthy explanations, you'll find:

  • Topic-wise interview questions
  • Important concepts to revise
  • Production scenario questions
  • Rapid-fire revision
  • Interview preparation tips

Let's get started.


Transformation Fundamentals Interview Questions

Questions

  1. What is a Transformation in Spark?
  2. Why are Transformations called lazy operations?
  3. What are the different types of Transformations?
  4. How do Transformations create new DataFrames?
  5. Why are Transformations immutable?
  6. Does a Transformation execute immediately?
  7. What happens internally after applying a Transformation?
  8. Can multiple Transformations be chained together?
  9. What is the advantage of chaining Transformations?
  10. Which Spark component manages Transformations?
  11. How do Transformations contribute to DAG creation?
  12. Give examples of commonly used Transformations.

Key Topics to Revise

  • Lazy Evaluation
  • Immutability
  • DAG
  • Logical Plan
  • DataFrame API

Action Fundamentals Interview Questions

Questions

  1. What is an Action in Spark?
  2. Why are Actions required?
  3. What happens when an Action is triggered?
  4. Which operations are considered Actions?
  5. Difference between show() and collect()?
  6. Difference between count() and take()?
  7. Why is collect() considered dangerous?
  8. What happens if multiple Actions are executed on the same DataFrame?
  9. Does every Action create a new Job?
  10. Can an Action trigger multiple Stages?
  11. What happens if an Action fails?
  12. How do Actions interact with the Driver Program?

Key Topics to Revise

  • Driver
  • Job
  • Stage
  • Task
  • Spark Execution

Lazy Evaluation Interview Questions

Questions

  1. What is Lazy Evaluation?
  2. Why does Spark use Lazy Evaluation?
  3. What are the advantages of Lazy Evaluation?
  4. When does Spark actually execute Transformations?
  5. How does Lazy Evaluation improve performance?
  6. What happens internally before an Action is executed?
  7. How does Spark optimize multiple Transformations?
  8. What role does Catalyst Optimizer play in Lazy Evaluation?
  9. How is Lazy Evaluation related to DAG?
  10. Can Lazy Evaluation reduce unnecessary computations?
  11. What are the limitations of Lazy Evaluation?
  12. Explain Lazy Evaluation using a real-world example.

Key Topics to Revise

  • Catalyst Optimizer
  • DAG
  • Logical Plan
  • Physical Plan
  • Execution Trigger

Narrow Transformation Interview Questions

Questions

  1. What is a Narrow Transformation?
  2. Why are Narrow Transformations faster?
  3. Which operations are Narrow Transformations?
  4. Does a Narrow Transformation trigger Shuffle?
  5. How does Spark execute Narrow Transformations?
  6. Difference between Narrow and Wide Transformations?
  7. Why are Narrow Transformations preferred?
  8. How do Narrow Transformations improve performance?
  9. Can multiple Narrow Transformations execute within the same Stage?
  10. Give real-world examples of Narrow Transformations.
  11. Why are filter() and select() considered Narrow Transformations?
  12. Which ETL operations commonly use Narrow Transformations?

Key Topics to Revise

  • Filter
  • Select
  • Map
  • FlatMap
  • Stage Execution

Wide Transformation Interview Questions

Questions

  1. What is a Wide Transformation?
  2. Why are Wide Transformations expensive?
  3. Which operations are Wide Transformations?
  4. Why do Wide Transformations trigger Shuffle?
  5. How do Wide Transformations create new Stages?
  6. Difference between groupBy() and filter() from Spark's execution perspective?
  7. Why are joins considered Wide Transformations?
  8. How do Wide Transformations impact network I/O?
  9. How do Wide Transformations affect Spark performance?
  10. Which ETL operations commonly involve Wide Transformations?
  11. How do you optimize Wide Transformations?
  12. How can excessive Wide Transformations slow down a Spark job?

Key Topics to Revise

  • Shuffle
  • groupBy
  • join
  • repartition
  • Stage Boundary

DAG & Lineage Interview Questions

Questions

  1. What is a DAG in Spark?
  2. Why does Spark create a DAG?
  3. What is Lineage in Spark?
  4. How does Lineage help in fault tolerance?
  5. Difference between DAG and Lineage?
  6. What happens if an Executor fails?
  7. How does Spark recover lost partitions?
  8. What is the relationship between DAG and Lazy Evaluation?
  9. How do Transformations build the DAG?
  10. How do Actions trigger DAG execution?
  11. How do you visualize the DAG?
  12. Why is understanding DAG important for optimization?

Key Topics to Revise

  • DAG
  • Lineage
  • Fault Tolerance
  • Spark UI
  • Execution Plan

Execution Flow Interview Questions

Questions

  1. What happens internally when a Spark application starts?
  2. What happens after an Action is triggered?
  3. How does Spark convert Transformations into a DAG?
  4. How does Catalyst Optimizer optimize the execution plan?
  5. What is the difference between a Logical Plan and a Physical Plan?
  6. How are Jobs, Stages, and Tasks created?
  7. What causes a new Stage in Spark?
  8. How are Tasks distributed across Executors?
  9. How does Spark execute multiple Transformations efficiently?
  10. What role does the Driver play during execution?
  11. How do Executors process Tasks?
  12. How do you analyze execution flow using Spark UI?

Key Topics to Revise

  • Driver
  • Executors
  • DAG
  • Logical Plan
  • Physical Plan
  • Jobs
  • Stages
  • Tasks

Production Scenario Questions

These are some of the most commonly asked production-based Spark Transformations & Actions interview questions.

  1. A Spark job is running successfully but taking much longer than expected. How would you identify whether the issue is caused by a Wide Transformation?

  2. A developer has used multiple collect() operations in a Spark application. What problems could this create?

  3. Your ETL pipeline contains dozens of chained Transformations. How does Spark optimize their execution?

  4. A Spark application is failing with OutOfMemoryException after calling collect(). How would you resolve it?

  5. How would you explain Lazy Evaluation to a team member who is new to Spark?

  6. A pipeline contains several groupBy() and join() operations. What performance issues would you expect?

  7. Your Spark UI shows many Stages for a relatively small job. What could be the reason?

  8. A Spark job contains only Narrow Transformations. What execution behavior would you expect?

  9. A DataFrame is used multiple times in different Actions. How would you optimize the application?

  10. Explain the complete execution flow from reading a file to writing the final output.

  11. How would you identify unnecessary Actions in a Spark application?

  12. What happens if an Executor fails during execution?

  13. How does Spark recover from failed Tasks?

  14. What would you monitor in Spark UI to understand execution performance?

  15. Explain a real production ETL pipeline where understanding Transformations and Actions helped optimize performance.


Spark Transformations & Actions Rapid Fire Questions

Quickly revise these concepts before your interview.

  • Transformation vs Action
  • Lazy Evaluation vs Immediate Execution
  • Narrow vs Wide Transformation
  • Logical Plan vs Physical Plan
  • DAG vs Lineage
  • Job vs Stage
  • Stage vs Task
  • Driver vs Executor
  • show() vs collect()
  • count() vs take()
  • filter() vs groupBy()
  • select() vs join()
  • map() vs flatMap()
  • repartition() vs coalesce()
  • cache() vs persist()

Quick Revision Cheat Sheet

TopicRemember
TransformationLazy operation that creates a new DataFrame/RDD
ActionTriggers Spark execution
Lazy EvaluationExecution starts only after an Action
Narrow TransformationNo Shuffle required
Wide TransformationRequires Shuffle
DAGExecution graph built by Spark
LineageTracks data transformations for fault tolerance
JobCreated when an Action is executed
StageGroup of Tasks separated by Shuffle boundaries
TaskSmallest unit of execution
DriverCoordinates the Spark application
ExecutorExecutes Tasks on worker nodes

Interview Preparation Tips

Before attending Spark interviews, ensure you can confidently explain:

  • The difference between Transformations and Actions.
  • Why Spark uses Lazy Evaluation.
  • The difference between Narrow and Wide Transformations.
  • How DAGs are created and executed.
  • The relationship between Jobs, Stages, and Tasks.
  • How Lineage enables fault tolerance.
  • Why collect() should be used carefully.
  • How multiple Transformations are optimized before execution.
  • How to analyze execution flow using Spark UI.
  • Real-world scenarios where execution behavior impacts performance.

A great way to prepare is to write a simple Spark program, predict how many Jobs and Stages will be created, and then verify your understanding using the Spark UI. This exercise helps bridge the gap between theory and real-world execution.


Common Mistakes Candidates Make

Many candidates know the syntax of Spark Transformations but struggle to explain what happens internally.

Some common mistakes include:

  • Assuming every Transformation executes immediately.
  • Confusing Transformations with Actions.
  • Not understanding why collect() can crash the Driver.
  • Mixing up Narrow and Wide Transformations.
  • Ignoring the role of Lazy Evaluation.
  • Forgetting that every Action creates a new Job.
  • Assuming every Transformation creates a new Stage.
  • Not understanding how Shuffle affects execution.
  • Confusing DAG with Lineage.
  • Relying on memorized definitions instead of understanding Spark's execution flow.

Avoiding these mistakes will help you answer follow-up interview questions with confidence and design more efficient Spark applications.


Conclusion

Transformations and Actions form the foundation of every Spark application. A solid understanding of these concepts helps you write efficient Spark code, interpret Spark UI correctly, optimize ETL pipelines, and troubleshoot production issues.

Instead of memorizing definitions, focus on understanding how Spark builds the execution plan, when execution begins, and why certain operations are more expensive than others.

Once you're comfortable with the topics covered in this guide, continue with the next article in this series: Spark Structured Streaming Interview Questions, where we'll explore micro-batches, triggers, checkpoints, watermarks, stateful processing, fault tolerance, and production-focused interview scenarios.

Soumya Ranjan Bisoyi

Written By

Soumya Ranjan Bisoyi

Data Engineer • Mentor • Educator

Helping aspiring Data Engineers learn SQL, Spark, Snowflake, Azure, and real-world Data Engineering concepts through practical, beginner-friendly content.