PySpark data engineering interview problem. Difficulty: intermediate. Pattern: Aggregation. About 16 minutes. Part of the Pro drill bank.
Electronics and Clothing revenue in one aggregate row. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
From df, return one row with electronics_revenue and clothing_revenue as conditional sums over those categories. Assign result.
Input: category amounts Output: electronics_revenue | clothing_revenue 220.0 | 70.0 Food is ignored by both conditional sums.
Topics: lakebench, pyspark, when, sum.
More PySpark interview questions · All interview problems · Learn data engineering
Interview-style drill: Electronics and Clothing revenue in one aggregate row.
From `df`, return one row with `electronics_revenue` and `clothing_revenue` as conditional sums over those categories. Assign `result`.