The sales table contains revenue rows by product.
Aggregate revenue per product, then rank products by total revenue using dense_rank with the highest revenue as rank 1. Return product_id, revenue, rn, sorted by rn, then product_id ascending.
These DataFrames are passed to solve(spark, dfs). Access one with dfs['name'].
sales6 rows| sale_id (int) | product_id (string) | revenue (double) |
|---|---|---|
| 1 | P1 | 100 |
| 2 | P2 | 80 |
| 3 | P3 | 80 |
| 4 | P4 | 20 |
| 5 | P5 | 80 |
| 6 | P1 | 10 |
Column names and order must match. Sort order is specified in the question.