Skip to content
Middle+10 views

What are transformation and action in Spark?

Practice

AI answer

In Spark, a transformation is a lazy transformation of the source dataset, such as filter, select, or map. It describes computations but usually doesn’t run them immediately. An action starts execution of the plan and returns a result or writes it, for example count(), collect(), show(), or write. Spark builds a plan from transformations and optimizes and executes it when an action is called. For example: df.filter("age >= 18").count() — filter is a transformation, and count is an action.