Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. Transformations vs actions

Batch & Streaming · Batch Processing

Transformations vs actions

Easystream-15
transformationsactionslazySpark

Question

What is the difference between transformations and actions in Spark?

Solution

Transformations build a new DataFrame/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.

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

Narrow vs wide (preview)

Some transforms stay in-partition (narrow). Others need shuffle (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.

PreviousNext