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
SQL on Spark — window functions, MERGE, query plans and optimizer behaviour.
How Adaptive Query Execution merges small shuffle partitions at runtime, the settings that control it, and the cases where you still have to tune.
Both load files into Delta exactly once. The choice comes down to file volume over the table's lifetime, who maintains the pipeline, and how often you need to reload a subset.
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.
Identity keys, computed columns and defaults in Delta: what each guarantees, what it doesn't, and the concurrency trade-off that bites.
The five Delta MERGE patterns (upsert, insert-only, newer-wins, deletes, full sync), the errors that break them, and how to make them fast.
Query old Delta versions, compare them, recover from a bad write, and set retention correctly now that Runtime 18 changed the rules.
OPTIMIZE compacts, Z-ORDER sorts, VACUUM deletes. How each works, how to schedule them, and what predictive optimization and Runtime 18 changed.
Delta rejects mismatched writes by default. How to allow new columns, wider types, renames and drops on purpose, one write at a time.
Three fact table types answer three kinds of question: what happened, what's the position, and how far along is it. Build each on Delta Lake, and avoid summing what shouldn't be summed.
Facts that show up before their customer exists, and facts that show up weeks after the event. Inferred members, point-in-time joins and re-keying jobs on Delta Lake, with the trade-offs of each.
Three ways to make Delta skip files, compared on cost and flexibility, with a decision order, migration steps and when partitioning still wins.
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 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.
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.
One customer moves city. Four SCD types record it four different ways. See the rows each type produces, the SQL that writes them, and how to choose per column.
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.
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.
The three concepts that make Spark Structured Streaming behave predictably — explained with the failure modes you hit when you skip them.
Delta tables didn't make dimensional modeling obsolete. Here's how to pick the grain, split facts from dimensions, and build a star schema on Databricks that analysts can trust.
Why MERGE quietly rewrites far more data than it changes, and the three fixes that keep it fast: prune the target, deduplicate the source, compact after.
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.
Apply a day's customer address changes to a dimension table, closing old versions and inserting new ones, in a single MERGE.
Keep exactly one row per event_id — the latest by timestamp — from a bronze table that receives replays and retries.
Group raw page views into sessions using a 30-minute inactivity gap, with pure SQL window functions.
A fact-to-dimension join runs on one straggler task for 40 minutes. Diagnose the skew and fix it three different ways.
See exactly which files a MERGE rewrites, then watch partition pruning cut a 300 GB rewrite down to 4 GB.
The governance, Delta Lake and SQL topics the Databricks Data Engineer Associate exam leans on, with practice problems for each.