This topic describes how to use a sliding window function in Spark Streaming SQL.
What is a sliding window?
A sliding window is also called a hopping window. Unlike tumbling windows, sliding windows can overlap each other.
- If the value of slideDuration is less than that of windowDuration, the windows overlap, and each element is assigned to multiple windows.
- If the value of slideDuration is equal to that of windowDuration , the windows are tumbling windows.
Syntax of a sliding window function
GROUP BY HOPPING ( colName, windowDuration, slideDuration )
SELECT avg(inv_quantity_on_hand) qoh FROM kafka_inventory GROUP BY HOPPING (inv_data_time, interval 1 minute, interval 30 second)