Berserk Docs
Scalar FunctionsOther Functions

row_window_session

Assigns a session window to each row of a serialized row set based on a datetime column. A new session starts when the value is more than max_distance_from_first beyond the session start, or more than max_distance_between_neighbors beyond the previous value; the function returns the session's start datetime. A row set is serialized by the sort, top, top-hitters, or serialize operators; order-preserving operators (extend, project, where, ...) keep that property. Only valid in a serialized context.

Syntax

row_window_session(value, max_distance_from_first, max_distance_between_neighbors, restart)

Parameters

Prop

Type

Returns: datetime

Examples

Example 1

datatable(t:datetime)[
  datetime(2024-01-01 00:00:00),
  datetime(2024-01-01 00:00:30),
  datetime(2024-01-01 01:00:00)
]
| sort by t asc
| extend session = row_window_session(t, 1h, 1m)
t (datetime)session (datetime)
2024-01-01T00:00:00Z2024-01-01T00:00:00Z
2024-01-01T00:00:30Z2024-01-01T00:00:00Z
2024-01-01T01:00:00Z2024-01-01T01:00:00Z

On this page