All Spark labs

Spark execution playground Work in progress

This lab is still in development and is not yet complete. Features, lessons and animations may change.

Edit a supported example and experiment with partitions, executors and task slots.

PySpark playground

Supported code in this first version

Use one spark.table("event_sessions") or spark.table("orders"), an optional filter, then select(...) or groupBy(...).count()/agg(F.sum(...).alias(...)). Use one assignment per line, following an example. collect() is the supported action. Remove it to explore laziness. Imports do not run Python. Joins, UDFs, multiline chains, cache and other operations are not simulated.

Preparing the example…

Scenario settings

AQE off · source partitions assigned round-robin · illustrative shuffle hash. These settings control the simulation. They are not measurements from DuckDB or Spark.

Input partitions Running task Shuffle data

Try more partitions than available task slots to see work execute in waves. Compare the grouped and narrow examples to see why one needs an exchange.

Connect the animation to Spark Pills

Pill 2 · Lazy evaluation and DAG Pill 3 · The shuffle Explore the complete series
Model assumptions and sources

These are simplified Spark 3.5-style batch scenarios with AQE disabled, no pre-existing key partitioning, no cache, no retries and no modeled spills. The planning lab arranges eight source rows into four teaching partitions. The playground assigns source partitions round-robin. Shuffle uses an illustrative hash, not Spark’s hash. Task slots assume one CPU per task. Animation ticks are not timings or performance predictions.

A grouped sum/count uses partial aggregation before exchange and final aggregation after exchange. The narrow select scenario has no exchange. Real physical plans, stage counts, partitioning and task placement depend on configuration, data sources, optimizations and runtime statistics. Loading the DuckDB sample is lab setup; it does not demonstrate a Spark read or measure Spark I/O.

Tasks execute work. Data blocks, rather than tasks, may be stored. Shuffle files, cached partitions and memory spills are distinct; these scenarios model shuffle outputs only.

References: Spark cluster overview, shuffle operations, adaptive query execution.