Lakehouse with PySpark + Delta Lake for Data Engineering - Full Course 2026 – Source Code
Build a complete local lakehouse with PySpark and Delta Lake, no cloud account needed: raw CityBikes files land daily, bronze loads them with Structured Streaming and checkpoints, silver cleans and types them with a quarantine, keeps station history with an SCD type 2 MERGE, applies member CDC inserts, updates and deletes, and removes duplicates with an insert-only MERGE, gold is refreshed incrementally from the Change Data Feed with replaceWhere, and CHECK constraints, quality checks and pytest guard the numbers. Plus ACID, schema enforcement and evolution, time travel and RESTORE, Delta SQL, OPTIMIZE, Z-ORDER and VACUUM, late data, audit history and a daily runner, plus generated columns, deletion vectors, shallow clones, liquid clustering and table properties.
- Duration
- 2:10:47 (35 chapters)
- Tools
- Python 3.13, PySpark 4.2.0, delta-spark 4.4.1, Java 21 (Temurin), pytest, deltalake, VS Code
Watch the tutorial
Chapters
- 0:00:0001. Intro: from raw files to a gold table
- 0:00:2002. Welcome: what a lakehouse is and what we'll build
- 0:06:2403. Setup: Java, a virtual environment and delta-spark
- 0:13:5404. Generating the CityBikes raw data
- 0:19:2905. Your first Delta table and the transaction log
- 0:24:1906. ACID transactions: appends and failed writes
- 0:28:0607. Schema enforcement and schema evolution
- 0:31:1308. Time travel, DELETE and RESTORE
- 0:34:5209. Delta with SQL: UPDATE, MERGE INTO and DESCRIBE
- 0:37:5010. Bronze: streaming raw files into Delta with checkpoints
- 0:44:3711. Streaming that keeps running: a live trigger
- 0:47:1812. Silver stations: history with SCD type 2 and MERGE
- 0:52:1913. Silver rides: types, quarantine and a MERGE that removes duplicates
- 0:59:5314. Silver members: applying CDC inserts, updates and deletes
- 1:03:4215. Day two arrives: incremental loads end to end
- 1:07:2016. Change Data Feed: what exactly changed?
- 1:10:0717. Gold: business tables with incremental replaceWhere
- 1:14:3418. Querying the lakehouse: SQL reports and an as-of join
- 1:17:0619. Sharing gold with business users: a CSV export
- 1:18:3420. Reading Delta without Spark: the deltalake package
- 1:20:0021. Data quality: constraints and checks
- 1:23:4022. Unit testing the cleaning rules with pytest
- 1:26:3123. Maintenance: OPTIMIZE, Z-ORDER and VACUUM
- 1:35:1024. The full pipeline: one command, two days, safe reruns
- 1:40:5525. Scheduling the pipeline with a daily runner
- 1:43:0826. Recovering from a bad run with RESTORE
- 1:44:5927. Generated columns and the table builder API
- 1:47:3028. Deletion vectors: fast deletes without rewriting files
- 1:50:0829. Shallow clones: a free test copy of a gold table
- 1:52:1130. Liquid clustering: the modern alternative to partitions and Z-order
- 1:54:4331. Table properties, log retention and checkpoints
- 1:57:2532. Delta Lake best practices checklist
- 1:59:3233. Common errors and how to fix them
- 2:02:4934. Lakehouse interview questions, answered
- 2:06:1735. Recap and next steps
What's in the zip
bike-lakehouse/.gitignorebike-lakehouse/01_first_table.pybike-lakehouse/02_acid.pybike-lakehouse/03_schema.pybike-lakehouse/04_time_travel.pybike-lakehouse/05_change_feed.pybike-lakehouse/06_constraints.pybike-lakehouse/07_vacuum.pybike-lakehouse/08_sql.pybike-lakehouse/09_audit.pybike-lakehouse/10_reports.pybike-lakehouse/11_late_rides.pybike-lakehouse/12_recover.pybike-lakehouse/13_live_stream.pybike-lakehouse/14_export.pybike-lakehouse/15_no_spark.pybike-lakehouse/16_generated.pybike-lakehouse/17_deletion_vectors.pybike-lakehouse/18_clone.pybike-lakehouse/19_clustering.pybike-lakehouse/20_properties.pybike-lakehouse/HOW_TO_RUN.txtbike-lakehouse/INTERVIEW.mdbike-lakehouse/LICENSEbike-lakehouse/MANIFEST.sha256bike-lakehouse/PLAN.mdbike-lakehouse/README.mdbike-lakehouse/bronze.pybike-lakehouse/gen_data.pybike-lakehouse/gold.pybike-lakehouse/lake.pybike-lakehouse/maintain.pybike-lakehouse/members.pybike-lakehouse/peek.pybike-lakehouse/quality.pybike-lakehouse/requirements.txtbike-lakehouse/rides.pybike-lakehouse/run_daily.shbike-lakehouse/run_pipeline.pybike-lakehouse/stations.pybike-lakehouse/test_rides.py
How to run
Python 3.10+ (tested with 3.13) and Java 17 or 21. Works on macOS, Linux and Windows (WSL recommended; native Windows needs winutils). Run every command from the project folder. The first run downloads the Delta Lake jars once.
python -m venv .venv
source .venv/bin/activate (Windows: .venv\Scripts\activate)
pip install -r requirements.txt
python gen_data.py
python run_pipeline.py
python gen_data.py --day 2
python run_pipeline.py
python peek.py gold daily_station_statsSee HOW_TO_RUN.txt for the full lesson order, Windows steps and common errors, and README.md for what every file does.
Data
All data is generated by gen_data.py and is fictional (a city bike-sharing service called CityBikes). No downloads, accounts or cloud services are needed.
Next step
New to Spark? The free PySpark for Data Engineering code is here too, and so are the Kafka and dbt course projects.
File: lakehouse-delta-lake-data-engineering-code.zip
Size: 28.9 KB (29,629 bytes)
SHA-256:49815060e087b34d57bdda3fb5ce1adb61c54682f84e342e82a4770b79752c02
Licence: code is released under the MIT licence, copyright PyInns. See LICENSE and README inside the zip. Free learning code, not production code.