internalsGet Pro

Module 08 · Lesson 12 of 14Pro

Writing efficient Spark jobs

Level
Advanced
Topic
Batch processing with Spark
Reading time
18 min

When you finish this page you can

  1. Find the four places a PySpark job does work nobody asked for, by reading its query plan before it runs.
  2. Explain why a Python UDF in a filter stops partition pruning and pushdown, and replace it with built-in functions.
  3. Choose how many output files a job writes, and when to use coalesce, repartition or neither.
  4. Rerun one day of a partitioned output without deleting the other days.

Builds on 4 lessons

Start with lesson 516 min
  1. Lazy evaluation and Spark query plans16 min
  2. Shuffles: the most expensive step in Spark17 min
  3. Joins at scale: broadcast and sort-merge17 min
  4. The small files problem17 min

A 20-minute job still running at 04:00

is an online store in India. Its apps send about 200 million click events a day, and they land in S3 as , one folder per day: clicks/event_date=2027-11-21/. Meera, a data engineer on Kartly’s data team, runs the Spark jobs that turn these files into tables the ML team and the analysts read.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan