Explain what a tumbling window and its trigger are in Spark Structured Streaming.
💡 Model Answer
In Spark Structured Streaming, a tumbling window is a fixed‑length, non‑overlapping time window that aggregates events that arrive within that interval. For example, a 5‑minute tumbling window will group all records that arrive between 12:00–12:05, 12:05–12:10, etc. The window is defined by a duration and an optional offset. A trigger controls when the streaming query emits results. The default trigger is a continuous micro‑batch that runs as soon as data arrives, but you can set a trigger to run every N seconds, once per day, or on demand. When you use a tumbling window, you often pair it with a trigger that defines how often you want to output the aggregated results. For instance, you might set a trigger of 30 seconds so that every 30 seconds Spark will compute the aggregates for the last 5‑minute window and emit them. Triggers are crucial for balancing latency and throughput; a very frequent trigger can increase latency but reduce batch size, while a long trigger reduces overhead but increases latency.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500