Apache Spark Interview Question: What is the difference between action and transformation in Apache Spark?
In Apache Spark, there is a fundamental distinction between actions and transformations.
Transformations:
Transformations in Apache Spark are operations that are applied to RDDs (Resilient Distributed Datasets) to create a new RDD. These operations are lazy, meaning they are not executed immediately. Instead, they create a lineage of transformations that are only executed when an action is called.
Some common transformations in Apache Spark include map
, filter
, flatMap
, and reduceByKey
.
Actions:
Actions in Apache Spark are operations that trigger the execution of the transformation lineage and produce a result. These operations are not lazy and are executed immediately when called.
Some common actions in Apache Spark include collect
, count
, take
, saveAsTextFile
.
It is important to understand the difference between actions and transformations in Apache Spark to optimize the performance of your Spark jobs and efficiently process large datasets.

Please login or Register to submit your answer