Transformations vs Actions

Here is the thing that surprises everyone coming from SQL. When you write df.filter(...).groupBy(...).agg(...), nothing runs. Spark does not read a single row. You have only described work. The description is called a transformation, and transformations are lazy: they build up a plan and return immediately. The data moves only when you call an action. Why a database can hide this and Spark cannot In SQL, a statement is a complete unit: you send it, it runs, you get rows. There is no gap between describing and executing. Spark deliberately keeps that gap open so it can see your entire chain of transformations before it commits to a plan. Seeing the whole chain lets it collapse steps, push filters down to the read, and skip work you do not actually need. Laziness is not a quirk; it is how Sp

About This Interactive Section

This section is part of the How a Spark Job Runs lesson on DataDriven, a free data engineering interview prep platform. Each section includes explanations, worked examples, and hands-on code challenges that execute in real time. SQL queries run against a live PostgreSQL database. Python runs in a sandboxed Docker container. Data modeling problems validate against interactive schema canvases. All content is framed around what data engineering interviewers actually test at companies like Meta, Google, Amazon, Netflix, Stripe, and Databricks.

How DataDriven Lessons Work

DataDriven combines four interview rounds (SQL, Python, Data Modeling, Pipeline Architecture) with adaptive difficulty and spaced repetition. Easy problems get harder as you improve. Weak concepts resurface until you master them. Your readiness score tracks progress across every topic interviewers test. Every lesson section ends with problems you solve by writing and running real code, not by picking multiple-choice answers.