Spark Masterclass is a free, Apache-2.0-licensed online book that teaches Apache Spark 4.3 by running it. It has 92 chapters in 14 parts, from how Spark runs your code through Spark SQL, Spark Connect, file formats, performance, Structured Streaming, lakehouse tables, Spark Declarative Pipelines, machine learning, production operations, extension APIs and engine internals. Each chapter has the exact code that ran, pinned to pyspark 4.3.0, and the real output saved next to it, including the query plans Spark printed and the metrics the Spark UI reported. The examples use one month of public New York City taxi trip data and run on a laptop.
What every chapter has
Most Spark material stops at the API. Spark Masterclass follows each call through planning, execution, storage and failure, and it shows the evidence for each step.
- The exact code that ran. A script under code/ in the repository, pinned to pyspark==4.3.0, that produces every result the chapter states.
- Its real output. Saved next to the script: the query plans Spark printed and the numbers the Spark UI reported.
- Diagrams of the mechanism. Where the data goes, which operator runs, and what the engine keeps.
- Figures and animations from saved output. So that a shuffle, a plan or a commit is visible, not only described.
What the book covers
The book has 92 chapters in 14 parts. Read it from the start, or go directly to the part about the mechanism you need to understand. Each chapter title links to the chapter in the online book.
Part I: BackgroundChapters 1 to 4
Part II: Getting startedChapters 5 to 8
Part III: DataFrames and the other APIsChapters 9 to 14
Part IV: Spark SQLChapters 15 to 23
Part V: Spark ConnectChapters 24 to 30
Part VI: Files, formats and data sourcesChapters 31 to 39
- 31.Files as files, globs and metadata
- 32.Text, logs and CSV
- 33.JSON: inference, drift and quarantine
- 34.Structs, arrays, maps and higher-order functions
- 35.VARIANT: landing, profiling and editing
- 36.XML, Avro and Protobuf
- 37.Documents, images, audio and tables for blobs
- 38.Spark on object storage
- 39.Databases over JDBC
Part VII: PerformanceChapters 40 to 47
Part VIII: StreamingChapters 48 to 53
Part IX: Lakehouse tablesChapters 54 to 55
Part X: Declarative PipelinesChapters 56 to 62
Part XI: Machine learning and applied algorithmsChapters 63 to 69
Part XII: Running Spark in productionChapters 70 to 78
Part XIII: Extending SparkChapters 79 to 87
Part XIV: InternalsChapters 88 to 92
How to run the examples
Every example is designed to run on a laptop. The chapter environment pins pyspark==4.3.0, and the data is one month of public New York City taxi trip records, which the setup script downloads (the repository does not redistribute it).
Requirements:
- Python 3.11 or later
- Java 17, 21 or 25
- uv, for the chapter environment
- A POSIX shell for the data and utility scripts
git clone https://github.com/open-lakehouse/spark-masterclass && cd spark-masterclass
./code/common/get_data.sh # one month of NYC taxi trips
cd code && uv sync # creates the environment with pyspark 4.3.0
uv run python ch07/quickstart.pySome chapters need more: Docker for catalogs, Kafka or Kubernetes with kind, extra Maven packages, or an NVIDIA GPU. Each chapter states its requirements at the start.
How the book is verified
Each technical result in the text comes from a script in the repository's code/ directory, and the output of that script is saved next to it. When the book quotes a query plan, a row count or a Spark UI metric, the saved output is the source. The prose is written in ASD-STE100 Simplified Technical English, a controlled language for technical text, and the repository includes a checker for it.
Frequently asked questions
- What is Spark Masterclass?
- Spark Masterclass is a free, open-source online book about Apache Spark 4.3. It explains how Spark plans and runs work, from DataFrames and SQL to Spark Connect, Structured Streaming, Spark Declarative Pipelines and engine internals, and it backs every technical result with runnable code and saved output.
- Which version of Apache Spark does Spark Masterclass cover?
- Apache Spark 4.3. The example environment pins pyspark==4.3.0, so the plans and output in the book come from that release.
- What does Spark Masterclass cover?
- 92 chapters in 14 parts: Background, Getting started, DataFrames and the other APIs, Spark SQL, Spark Connect, Files, formats and data sources, Performance, Streaming, Lakehouse tables, Declarative Pipelines, Machine learning and applied algorithms, Running Spark in production, Extending Spark, and Internals.
- How are the examples in Spark Masterclass verified?
- Each technical claim is tied to a script in the repository's code/ directory and to the output that script saved, including printed query plans and Spark UI metrics. A reader can run the same script and compare the result.
- Do I need a cluster or a managed platform to follow Spark Masterclass?
- No. The examples are designed to run on a laptop with Python 3.11 or later, Java 17, 21 or 25, and uv. Some chapters need more, such as Docker for catalogs, Kafka or Kubernetes with kind, extra Maven packages, or an NVIDIA GPU; each chapter states its requirements at the start.
- Is Spark Masterclass free?
- Yes. The book is free to read online and its text and code are licensed under the Apache License 2.0, the same license as Apache Spark. Corrections are accepted as GitHub issues or pull requests.
Keep going
- Spark Matrix: Apache Spark features across managed Spark platforms
- Compute engines for the open lakehouse
- Open source data engineering: the reference stack
