PySpark data engineering interview problem. Difficulty: intermediate. Pattern: Aggregation. About 16 minutes. Part of the Pro drill bank.
Median amount for an odd-sized fixture (not the mean). Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Return one row with median_amount = median of amount. The fixture sorts to 1,2,3,4,100 so the median is 3 (mean would be 22). Assign result. Do not use percentile_approx.
Input: amounts 1,2,3,4,100 Output: median_amount 3.0 Odd count: middle of sorted values.
Topics: lakebench, pyspark, median, orderBy.
More PySpark interview questions · All interview problems · Learn data engineering
Interview-style drill: Median amount for an odd-sized fixture (not the mean).
Return one row with `median_amount` = median of `amount`. The fixture sorts to 1,2,3,4,100 so the median is 3 (mean would be 22). Assign `result`. Do not use percentile_approx.