pandas 3 Migration Guide: Copy-on-Write, str Dtype, pd.col and Faster read_csv (2026) Python multiprocessing Tutorial: Pool, ProcessPoolExecutor, Queues and Locks (2026) YOLO26 Object Detection in Python with Ultralytics: Detect, Count, Track and Export (2026) Remove Background from Image in Python with rembg: Models, Batch, Masks and CLI (2026) FastAPI File Upload Tutorial: UploadFile, Multiple Files, Validation and Size Limits (2026) Ollama Python Tutorial: Run Local LLMs with Chat, Streaming, Structured Outputs, Tools and Embeddings (2026) Python sqlite3 Tutorial: Tables, Transactions, JSON and Upserts with the Built-in Database (2026) Convert Python to EXE with PyInstaller: One-File Apps, Data Files and Hidden Imports (2026) Two-Factor Authentication in Python with pyotp: TOTP, QR Codes and FastAPI (2026) Hash Passwords in Python with Argon2: pwdlib, argon2-cffi and bcrypt Migration (2026) Encrypt and Decrypt in Python with Fernet: Strings, Files and Passwords (2026) psutil Tutorial: Monitor CPU, Memory, Disk and Processes in Python (2026) PyMuPDF Tutorial: PDF to Image, Extract Text and Images in Python (2026) MoviePy 2 Tutorial: Edit Videos with Python (Trim, Text, Merge, Audio) 2026 FastAPI Dependency Injection with Depends: Annotated, Yield and Overrides (2026) HTML to PDF in Python with WeasyPrint and Jinja2: Invoices and Reports (2026) Extract Tables from PDF in Python with pdfplumber: CSV, Excel and pandas (2026) OCR in Python: Extract Text from Images and Scanned PDFs with RapidOCR (2026) Text to Speech in Python with Piper: Offline Natural Voices, WAV Files and a TTS API (2026) Speech to Text in Python with faster-whisper: Transcribe Audio and Make Subtitles (2026) Send Email with Python: smtplib, HTML, Attachments and Bulk Mail (2026) Python QR Code Generator: Styled QR Codes with qrcode (2026) Pillow 13: Resize, Crop and Watermark Images in Python (2026) Parallel Programming with Dask in Python 2026: Intro Guide MarkItDown: Convert Files to Markdown for LLMs in Python (2026) Plotly Express: Interactive Charts in Python (2026) pandera: Validate pandas DataFrames in Python (2026) jsonschema: Validate JSON Data in Python (2026) Faker: Generate Fake Test Data in Python (2026) RapidFuzz: Fuzzy String Matching in Python (2026) View all in this category →

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

Watch on YouTube

Chapters

  1. 0:00:0001. Intro: from raw files to a gold table
  2. 0:00:2002. Welcome: what a lakehouse is and what we'll build
  3. 0:06:2403. Setup: Java, a virtual environment and delta-spark
  4. 0:13:5404. Generating the CityBikes raw data
  5. 0:19:2905. Your first Delta table and the transaction log
  6. 0:24:1906. ACID transactions: appends and failed writes
  7. 0:28:0607. Schema enforcement and schema evolution
  8. 0:31:1308. Time travel, DELETE and RESTORE
  9. 0:34:5209. Delta with SQL: UPDATE, MERGE INTO and DESCRIBE
  10. 0:37:5010. Bronze: streaming raw files into Delta with checkpoints
  11. 0:44:3711. Streaming that keeps running: a live trigger
  12. 0:47:1812. Silver stations: history with SCD type 2 and MERGE
  13. 0:52:1913. Silver rides: types, quarantine and a MERGE that removes duplicates
  14. 0:59:5314. Silver members: applying CDC inserts, updates and deletes
  15. 1:03:4215. Day two arrives: incremental loads end to end
  16. 1:07:2016. Change Data Feed: what exactly changed?
  17. 1:10:0717. Gold: business tables with incremental replaceWhere
  18. 1:14:3418. Querying the lakehouse: SQL reports and an as-of join
  19. 1:17:0619. Sharing gold with business users: a CSV export
  20. 1:18:3420. Reading Delta without Spark: the deltalake package
  21. 1:20:0021. Data quality: constraints and checks
  22. 1:23:4022. Unit testing the cleaning rules with pytest
  23. 1:26:3123. Maintenance: OPTIMIZE, Z-ORDER and VACUUM
  24. 1:35:1024. The full pipeline: one command, two days, safe reruns
  25. 1:40:5525. Scheduling the pipeline with a daily runner
  26. 1:43:0826. Recovering from a bad run with RESTORE
  27. 1:44:5927. Generated columns and the table builder API
  28. 1:47:3028. Deletion vectors: fast deletes without rewriting files
  29. 1:50:0829. Shallow clones: a free test copy of a gold table
  30. 1:52:1130. Liquid clustering: the modern alternative to partitions and Z-order
  31. 1:54:4331. Table properties, log retention and checkpoints
  32. 1:57:2532. Delta Lake best practices checklist
  33. 1:59:3233. Common errors and how to fix them
  34. 2:02:4934. Lakehouse interview questions, answered
  35. 2:06:1735. Recap and next steps

What's in the zip

  • bike-lakehouse/.gitignore
  • bike-lakehouse/01_first_table.py
  • bike-lakehouse/02_acid.py
  • bike-lakehouse/03_schema.py
  • bike-lakehouse/04_time_travel.py
  • bike-lakehouse/05_change_feed.py
  • bike-lakehouse/06_constraints.py
  • bike-lakehouse/07_vacuum.py
  • bike-lakehouse/08_sql.py
  • bike-lakehouse/09_audit.py
  • bike-lakehouse/10_reports.py
  • bike-lakehouse/11_late_rides.py
  • bike-lakehouse/12_recover.py
  • bike-lakehouse/13_live_stream.py
  • bike-lakehouse/14_export.py
  • bike-lakehouse/15_no_spark.py
  • bike-lakehouse/16_generated.py
  • bike-lakehouse/17_deletion_vectors.py
  • bike-lakehouse/18_clone.py
  • bike-lakehouse/19_clustering.py
  • bike-lakehouse/20_properties.py
  • bike-lakehouse/HOW_TO_RUN.txt
  • bike-lakehouse/INTERVIEW.md
  • bike-lakehouse/LICENSE
  • bike-lakehouse/MANIFEST.sha256
  • bike-lakehouse/PLAN.md
  • bike-lakehouse/README.md
  • bike-lakehouse/bronze.py
  • bike-lakehouse/gen_data.py
  • bike-lakehouse/gold.py
  • bike-lakehouse/lake.py
  • bike-lakehouse/maintain.py
  • bike-lakehouse/members.py
  • bike-lakehouse/peek.py
  • bike-lakehouse/quality.py
  • bike-lakehouse/requirements.txt
  • bike-lakehouse/rides.py
  • bike-lakehouse/run_daily.sh
  • bike-lakehouse/run_pipeline.py
  • bike-lakehouse/stations.py
  • bike-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_stats

See 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.

Download source code

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.