A scenario for a data engineer · Junior and up
One task has been running for an hour
Patch · Your teammate
Friday, 10:30
A Spark join on Databricks between two billion order rows and a table of 300 stores is stuck. Almost every task finished in seconds and one is still going. One store holds nearly half the orders, and Spark did not broadcast the store table by itself.
What do you do?
Tap the one you would do. The answer opens below.
Show the best callThe best call
Add a broadcast hint for the small store table, so the join needs no shuffle.
Every worker gets the whole store table, the orders are never shuffled by store, and the job finishes in minutes.
Why
A skewed key puts most rows in one shuffle partition, and one task has to work through all of it. A broadcast join sends the small table to every worker, so the big table is never shuffled by that key. Spark usually broadcasts a table this small by itself, and adaptive query execution can split skewed partitions. When neither happens, a broadcast hint fixes it.
Read it in the Databricks docs (opens in a new tab)The other two
- Works, at a price. Add a random salt to the store key on the orders, and copy each store once for every salt value.
- It works, and the query is now harder to read and easier to get wrong.
- A poor call. Double the number of workers.
- The stuck task is one task. It runs on one worker however many you add.
The words in this scenario
- Broadcast join.
- A join where Spark sends a copy of the small table to every worker, so the large table does not have to be moved around to meet it. In the docs (opens in a new tab)
Go deeper on brickster.ai
- Apache Spark: what changed recentlyNews, releases, videos and questions on it, gathered daily.
- Drill Spark in PracticeShort questions with the reason after each answer.
More scenarios
- The cleaning step takes most of the run · data engineer
- The nightly job no longer fits in the night · data engineer
- Twenty dashboards, one heavy query · data engineer
- All 47 scenarios
Had one like this at work? Send it to us: the best tickets come from real incidents.
Checked against the Databricks documentation on . brickster.ai is independent and is not affiliated with Databricks.