Why AQE Coalesces Shuffle Partitions (and When It Can't Help)
How Adaptive Query Execution merges small shuffle partitions at runtime, the settings that control it, and the cases where you still have to tune.
Topic
DataFrame patterns, performance tuning and the Spark execution model from Python.
How Adaptive Query Execution merges small shuffle partitions at runtime, the settings that control it, and the cases where you still have to tune.
Which trigger mode to pick and what it costs, what actually lives in a checkpoint, and the three conditions exactly-once depends on — one of which is your code.
A CDC feed sends duplicates and out-of-order changes. Build a MERGE that keeps the latest row per key, ignores late events and is safe to replay.
Enable Change Data Feed and read row-level inserts, updates and deletes by version to refresh downstream Delta tables incrementally.
The five Delta MERGE patterns (upsert, insert-only, newer-wins, deletes, full sync), the errors that break them, and how to make them fast.
Delta rejects mismatched writes by default. How to allow new columns, wider types, renames and drops on purpose, one write at a time.
Why Delta tables collect tiny files, how to measure it, and the writer fixes and compaction strategies that stop it coming back.
Read _delta_log yourself: what commits and checkpoints contain, how readers build snapshots, and how concurrent writers avoid corruption.
Build your first declarative pipeline end to end — streaming tables, materialized views, flows and the pipeline graph — using the pyspark.pipelines API that replaced import dlt.
A practical pattern for turning deeply nested structs, arrays, and maps into flat, queryable tables — without hardcoding every field path.
50 PySpark interview questions across transforms, joins, windows, partitioning, performance, streaming, Delta Lake, and system design — with answers, not just questions.
A field checklist for slow or expensive PySpark jobs: baseline first, then read less, shuffle less, balance the work, compute smarter, use memory well and write right.
A field guide to when built-ins, Pandas UDFs and plain Python UDFs actually make sense, with the serialization cost that explains the gap between them.
Running totals, rankings, lag/lead comparisons, and moving averages in PySpark — what a window actually is under the hood and where it gets expensive.
A practical route through the Spark UI: map a slow query to its stage, read the summary metrics, and recognise skew, spill, tiny files and GC pressure.
repartition shuffles to any count with even sizes; coalesce merges without a shuffle but only downwards. When to use each, and the coalesce(1) trap.
Expire the old version and insert the new one in a single Delta MERGE. The staged-union pattern, a PySpark version, the tests that catch broken history, and when to hand it to AUTO CDC.
How each Spark join strategy moves data, the rules Spark uses to pick one, how AQE changes the choice at runtime, and when to step in with a hint.
cache and persist keep results but remember the lineage; checkpoint keeps only the result. Storage levels, when each pays off, and what to use on serverless.
Find the hot key behind a stage that never finishes, then fix it with AQE skew joins, key cleanup, hot-key isolation or salting, in that order.
How executor and driver memory is actually divided, why tasks spill, and how to diagnose and fix each kind of out-of-memory error instead of just adding RAM.
The three concepts that make Spark Structured Streaming behave predictably — explained with the failure modes you hit when you skip them.
Identity columns, hash keys and ROW_NUMBER sequences all produce surrogate keys on Delta Lake. They differ on concurrency, collisions, reproducibility and join cost. Here's how to choose.
A test pyramid that actually fits a Spark pipeline — fast unit tests for transform logic, a shared local SparkSession, and a pattern for Delta-backed integration tests.
Four window patterns cover almost every pipeline need: latest-row dedupe, sessionization, running totals and gap detection — with the performance traps of each.
Adaptive Query Execution merges tiny post-shuffle partitions at runtime, so stop hand-tuning spark.sql.shuffle.partitions for every job.
Turn an orders feed with a nested customer struct and an items array into one flat row per order item.
A fact-to-dimension join runs on one straggler task for 40 minutes. Diagnose the skew and fix it three different ways.