Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Peak parallel batch workers

SQL data engineering interview problem. Difficulty: advanced. Pattern: CTEs. About 18 minutes. Part of the Pro drill bank.

Given batch_jobs(job_id, start_time, end_time), compute the minimum number of parallel workers needed so no two overlapping jobs share a worker. That number equals the maximum number of jobs running at the same time. Return one column peak_workers. Treat a job as active on [start_time, end_time) (counts at start, not at end).

Examples

Input: batch_jobs (morning cluster) job_id | start_time | end_time 1 | 2024-01-01 09:00:00 | 2024-01-01 11:00:00 2 | 2024-01-01 10:00:00 | 2024-01-01 12:00:00 3 | 2024-01-01 10:30:00 | 2024-01-01 11:30:00 Output: peak_workers | 3 | Why this passes: All three jobs overlap between 10:30 and 11:00, so peak concurrency is 3.

Topics: lakebench, sql, concurrency, sweep.

More SQL interview questions · All interview problems · Learn data engineering

advanced

Peak parallel batch workers

Interview-style drill: Minimum workers needed equals peak concurrency.

Given `batch_jobs(job_id, start_time, end_time)`, compute the minimum number of parallel workers needed so no two overlapping jobs share a worker. That number equals the maximum number of jobs running at the same time. Return one column `peak_workers`. Treat a job as active on `[start_time, end_time)` (counts at start, not at end).