- Tumble windows
- Hop windows
- Session windows
tumble() and hop() respectively. For session window, RisingWave supports it by a special type of window function frame, i.e. SESSION frame.
Time window function
Time window functions are used in the FROM clause. They take a table/source/materialized view, a time column and some other arguments as input, and assign each input row a time window by augmenting the row with two new columns:window_start and window_end. The two augmented columns represent the start and end of time windows respectively.
tumble() time window function
Tumbling windows are contiguous non-overlapping time intervals.

tumble() is as follows:
- table_or_source specifies the table/source/materialized view that needs to be assigned with time windows.
- time_col specifies the column to determine time windows on. It can be in either timestamp or timestamp with time zone format.
Example of timestamp with time zone format:
2022-01-01 10:00:00+00:00. - window_size specifies the size of each time window. It should be a constant value of
INTERVALtype. Example:INTERVAL '2 MINUTES'. The standard SQL format, which places time units outside of quotation marks (for example,INTERVAL '2' MINUTE), is also supported. - offset is an optional parameter that allows you to shift the starting point of each time window.
Example:
window_size = INTERVAL '10 MINUTES', offset = INTERVAL '2 MINUTES'will yield time window starts like2022-01-01 00:12:00+00:00.
taxi_trips, that consists of these columns: trip_id, taxi_id, completed_at, distance, and duration.
hop() time window function
The hop() time window function also assigns each row a time window with a fixed size, which is very similar to tumble(), except that the assigned time windows may overlap.

hop() time window function.
- table_or_source specifies the table/source/materialized view that needs to be assigned with time windows.
- time_col specifies the column to determine time windows on. It can be in either timestamp or timestamp with time zone format.
Example of timestamp with time zone format:
2022-01-01 10:00:00+00:00. - hop_size specifies the size of each hop, window_size specifies the size of each time window. Both should be constant values of
INTERVALtype. For example:INTERVAL '2 MINUTES'. The standard SQL format, which places time units outside of quotation marks (for example,INTERVAL '2' MINUTE), is also supported. - offset is an optional parameter that allows you to shift the starting point of each time window.
Example:
window_size = INTERVAL '10 MINUTES', offset = INTERVAL '2 MINUTES'will yield time window starts like2022-01-01 00:12:00+00:00.
Session windows
In RisingWave, session windows are supported by a special type of window function frame:SESSION frame. You can refer to Window function calls for detailed syntax.
Currently,
SESSION frame is only supported in batch mode and emit-on-window-close streaming mode.tumble() and hop() time window functions, that is, to assign each row a time window by augmenting it with window_start and window_end.

Window aggregations
Let’s see how we can perform time window aggregations.Tumble window aggregations
Below is an example of tumble window aggregation. In this example, we want to get the number of trips and the total distance for each tumbling window (2 minutes).Hop window aggregations
Below is an example of hopping window aggregation. In this example, we want to get the number of trips and the total distance within a two-minute window every minute.Session window aggregations
Below is an example of aggregation over session windows. In this example, we want to get the number of unique products viewed by each user in session gapped by 5 minutes interval, based on the example data in previous Session windows section.Handle gaps in time windows
If no events occur during specific intervals, gaps may appear in time windows. To ensure continuous and complete time windows, usegenerate_series() to fill in missing intervals.
Problem
Consider a dataset of taxi trips where each trip is recorded with a completion timestamp:2022-07-01 22:04:00 - 2022-07-01 22:06:00 is missing because no trips were recorded during that interval.
Solution
To ensure continuous time windows, we can generate a full range of expected time windows and LEFT JOIN them with the aggregated results.0 filling for missing intervals.
Window joins
You can join a time window with a table, or another time window that is of the same type and has the same time attributes.Joins with tables
Let’s see how you can join a time window with a table. Suppose that you have a simple tabletaxi_simple that has the following data:
Window joins
You can join two tumble time windows to get both trip and fare information. The corresponding tables aretaxi_trips and taxi_fare.
The taxi_fare table has the following data: