How a Spark job goes from your code to parallel work on a cluster: a driver plans, executors run, and nothing happens until an action fires.
Spark is a distributed engine where a driver compiles your operations into a plan and schedules it as tasks across executors, evaluating lazily — only when an action is triggered.
Apache Spark is the technology powering compute clusters and SQL warehouses in Databricks. Understanding driver/executor roles, shuffle boundaries, and lazy evaluation is what lets you reason about why a job is slow, where data moves, and what a query plan is actually doing.
The driver node maintains the SparkContext, interprets your commands, and runs the Spark master that coordinates executors; worker nodes run the executors that do the distributed work (one executor per worker).
Allocates the worker VMs and hands resources to the application — on Databricks the cluster and Spark session are configured and managed for you.
Each action launches a job; the scheduler splits it into stages at shuffle boundaries, and each stage runs as tasks — one task per partition.
The unit of parallelism: data is divided into partitions and each is processed by a single task, so partition count sets how much runs in parallel.
Every operation is a transformation (reads, joins, aggregations, casts — returns a new DataFrame) or an action (writes, count, display) — only actions execute work.
No logic runs until an action fires; Databricks then considers all transformations behind that action at once and picks an optimal plan based on the physical layout of the data.
write, count, display) triggers execution and launches one job.PySparkdf = spark.read.table("sales") # transformation — lazy, no work yet
result = (df
.filter(df.region == "EU") # narrow: stays within a partition
.groupBy("category").count()) # wide: shuffle → new stage boundary
result.write.saveAsTable("eu_counts") # ACTION — fires the job: stages run as tasks
groupBy, join, distinct) move data across the network and start a new stage — the usual bottleneck.collect() / toPandas() pull all results to the driver; on a large dataset that OOMs the single driver node.Verified against docs.databricks.com · June 2026