The customers table stores each customer's region, and orders stores their purchases.
Return region, customer_id, customer_name, total_spend for the highest-spending customer in each region. Break ties by the smaller customer_id. Sort by region ascending.
These DataFrames are passed to solve(spark, dfs). Access one with dfs['name'].
customers5 rows| customer_id (int) | customer_name (string) | region (string) |
|---|---|---|
| 1 | Maya | North |
| 2 | Leo | North |
| 3 | Nina | South |
| 4 | Omar | South |
| 5 | Sara | West |
orders6 rows| order_id (int) | customer_id (int) | amount (double) |
|---|---|---|
| 1 | 1 | 100 |
| 2 | 2 | 80 |
| 3 | 1 | 30 |
| 4 | 3 | 60 |
| 5 | 4 | 90 |
| 6 | 5 | 40 |
Column names and order must match. Sort order is specified in the question.