HR wants to audit high-earner compensation. You are tasked with retrieving profiles of the top 3 highest-paid employees in descending order of their salaries.
The processing pipeline will ingest the following local mock file structures (e.g. simulated as `dataset.csv`):
| id | name | salary |
|---|---|---|
| 1 | Alice | 120000 |
| 2 | Bob | 90000 |
| 3 | Charlie | 150000 |
| 4 | David | 85000 |
| 5 | Eve | 130000 |
id,name,salary 1,Alice,120000 2,Bob,90000 3,Charlie,150000 4,David,85000 5,Eve,130000
Copy this starter template to write the data transformation logic:
# starter.py - Top Paid Employees
from pyspark.sql import SparkSession
from pyspark.sql.functions import col
def top_paid():
spark = SparkSession.builder.appName("TopPaid").getOrCreate()
# TODO: Read dataset.csv, sort by salary desc, limit 3
pass
if __name__ == "__main__":
top_paid()orderBy(col("salary").desc()) to sort the rows from highest salary to lowest.
name and salary to keep the payload lightweight.
limit(3) to extract only the top 3 records, and print the results using show().