WINDOW

Generic Description

Bucket rows into time windows for later aggregation.

Simple example:

MATCH (r:Reading) WINDOW TUMBLING 300 ON r.ts RETURN r

Consumer-Level Explanation

Use WINDOW when the query must bucket rows into time windows for later aggregation and the planner needs to see that operation as part of the Cypher row pipeline. Keep the clause explicit because it controls row grain, variable scope, and what later clauses are allowed to reference.

More Detailed Explanation

WINDOW is the bridge from raw event history to rollups. In the current AST and docs, tumbling windows are the explicit implemented strategy, which already covers a large class of operational and analytics queries.

What this clause is really for:

Advanced Example

This example keeps WINDOW inside a complete query pipeline so the clause boundary, visible variables, and returned row shape are clear to planner tooling.

MATCH (s:Sensor)-[r:EMITS]->(m:Measurement)
TIME r.ts BETWEEN datetime('2025-01-01T00:00:00Z') AND datetime('2025-01-07T00:00:00Z')
WITH s, r, m, date_trunc('hour', r.ts) AS bucket, properties(m) AS payload
RETURN s.sensor_id, bucket, keys(payload) AS payload_keys, unpivot(payload) AS metrics
ORDER BY bucket DESC

Real Use Cases

Real Limitations And Tradeoffs