Batch & Streaming · Batch Processing

Transformations vs actions

EasytransformationsactionslazySpark

Interview question

What is the difference between transformations and actions in Spark?

How to answer

The short answer

Transformations build a new /RDD from an existing one without computing yet: filter, select, join, groupBy, withColumn.

Actions force Spark to compute and return/store a result: count, collect, show, take, write, foreach.

Output
transformations (lazy)          action (eager)
filter -> select -> join  --->  write.parquet / count
         \______ plan ______/

Narrow vs wide (preview)

Some transforms stay in-partition (narrow). Others need (wide). Actions decide *when*; dependency type decides *how expensive*.

Interview tip: List 3 transforms and 3 actions from memory. Say only actions create Spark jobs you see in the UI.