1. Lazy transformations
filter and select are transformations — they add to the plan but run no computation yet.
df.filter("revenue > 0").select("country", "revenue")Typorithm · medium
Step 1 of 8 · intro card
Transformations & Actions
Transformations (select, filter, map, groupBy) are lazy — they build a plan but compute nothing. Actions (collect, count, show, write) trigger execution of that plan.
Transformations such as filter, select, map, and groupBy are lazy: each one only appends a step to a logical plan, a DAG of operations, without touching any data.
Nothing actually runs until an action is called. Actions — collect(), count(), show(), write — force Spark to schedule and execute the accumulated plan.
This lazy-evaluation model lets Spark optimize the whole DAG (pruning columns, pushing down filters) before a single byte is read, which is why filtered.count() does the real work, not the filter chain itself.
Transformations are lazy and only build a plan.
Actions like count() trigger execution.
Spark optimizes the DAG before running.
const filtered = df.filter("revenue > 0").select("country", "revenue");
filtered.count();Connect each part of the code to the concept before you type.
filter and select are transformations — they add to the plan but run no computation yet.
df.filter("revenue > 0").select("country", "revenue")Assigning the chain stores a logical plan (a DAG of steps), not materialized data.
const filtered =count() is an action: it forces Spark to execute the whole plan and return a result.
filtered.count();Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.