SpinTheMic
Pro

Interview practice question

Window function very slow

Data Engineering · Spark · Intermediate

A job computing row_number over customer windows is very slow. Most customers have a few rows, but some have millions. What can you do?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Window functions shuffle and sort by the partition key, so skewed keys create huge tasks.
  • Find the hot keys.
  • If only top N per customer is needed, filter or pre-aggregate first.
  • Handle hot customers separately.
  • Use alternatives like max_by or groupBy with struct when only the latest row is needed.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics