Interview practice question
Skewed aggregation on a hot key
Data Engineering · Spark · Experienced
A groupBy on merchant_id is slow because one merchant has 40 percent of all transactions. How do you fix it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- All rows for the hot key go to one task.
- Two-stage aggregation: add a salt, aggregate by key and salt, then aggregate again by key.
- Works for aggregations that can be combined, like sum and count.
- Distinct counts need care, like approximate sketches.
- AQE helps skewed joins more than skewed aggregations.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.