Windows

A window is a stored group of rows that has a retention policy, such as "KEEP 10 MINUTES" or "KEEP 50 ROWS".

A query may operate on one or more windows, as well as on a stream. This enables you to relate a new row to rows that arrived earlier. It also allows you to perform aggregate functions (for example, SUM(), AVG(), and so on) on all the data accumulated in a window.

Below is an example of a query on a window.

-- Create the window.
CREATE WINDOW StockTradeHistory
SCHEMA ...
KEEP 8 HOURS;
...
-- Query: Process data from "history" window and generate output.
INSERT INTO OutputStream...
SELECT StockSymbol, AVG(Price)
FROM StockTradeHistory;

Unless the window is defined with a KEEP ALL clause which allows it to accumulates messages indefinitely, rows from the window will eventually expire and be deleted from the window.