Time Windows & Aggregations
Windows group messages by time intervals for aggregation. Instead of reacting to every individual message, windows let you ask questions like “How many orders in the last 5 minutes?” or “What’s the average temperature over a rolling 10-minute window?”Window Types
LiteJoin supports three window types:Tumbling Windows
Fixed-size, non-overlapping intervals. Each message belongs to exactly one window. When the window closes, the aggregation fires and results are emitted.Sliding Windows
Fixed-size intervals that slide forward by a configurable step. Messages may appear in multiple windows.Session Windows
Dynamic intervals based on activity gaps. A session starts with the first message and closes when no new messages arrive within thegap duration.
Configuration
Common Fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Unique name for the window. |
type | string | yes | tumbling, sliding, or session. |
topic | string | yes | Topic to aggregate. |
query | string | yes | SQL aggregation query. |
sink | string | yes | Sink to emit results to. |
Type-Specific Fields
| Field | Applies To | Type | Description |
|---|---|---|---|
size | tumbling, sliding | duration | Window size (e.g., 5m, 1h). |
slide | sliding | duration | Slide interval. Must be ≤ size. |
gap | session | duration | Inactivity gap to close a session. |
Result Format
Window results are emitted asJoinResult objects, the same format as join results:
Combining Windows with Joins
You can use window aggregations as inputs to joins. For example, aggregate orders per region, then join with region metadata:Best Practices
- Choose the right window type. Tumbling for periodic reports, sliding for moving averages, session for activity-based grouping.
- Keep
sizereasonable. Larger windows hold more data in memory. Start with 5–15 minute windows. - Use
GROUP BYfor segmentation. Split aggregations by a dimension (region, user type, status) for richer insights. - Test with Studio. Use the visual windowing controls in LiteJoin Studio to experiment without writing complex config.