Member-only story
Pyspark Coding Interview Question
The Problem: You run an IoT pipeline processing sensor heartbeat logs with columns [sensor_id, timestamp]. Sensors are supposed to ping every 5 minutes. Write a PySpark query to identify all specific instances where a sensor had a gap in transmission of 15 minutes or longer between consecutive pings.
🔥 The 3-Second Hook
A sensor on a chemical reactor stops pinging for 22 minutes. Nobody notices.
By the time someone checks the logs, the temperature has already spiked past the safety threshold — and the “system” never raised an alarm, because technically, the sensor was still “connected.” It just… went quiet for a while.
This isn’t a hypothetical. This is what happens when you store heartbeat logs but never actually query them for gaps.
If you’re working with IoT pipelines, this is the one PySpark pattern you need to know cold — because it shows up in real production incidents, and it shows up in interviews too. 👇










