Lower duql sessions through the existing sessionize window kernel
Context#
The session stage needs deterministic ordering, interval-aware gaps and schema-based time units.
Decision#
Reuse sessionize in dftu.frame.window. Add a row index, stably sort by time then input position, add an order index, run one window operation, and restore row order. Measure the gap from the latest end; accept an optional end column and span, and return null for null time.
Build the end term as time plus duration times the unit factor before the window. With no duration role, omit the end column. Lower gap and max through time_value: duration literals convert to role units, numeric values remain unchanged. Reject negative gap and non-positive max. ISO time roles already use int64 microseconds.
Use a function-keyed union with factories for mutually exclusive window parameters. Treat session as a keyword only at stage start and gap, max, as as contextual words, so a field named session and max(...) still work elsewhere. Explain prints a session line after scan lines with keys, time, end, gap, max and name.
Why#
Reusing window ordering preserves determinism across workers. Building the end term in duql keeps the kernel free of unit logic. Contextual words avoid reserving existing field and function names.
Rejected options#
Do not add a second session kernel or move schema-unit conversion into it. Evidence: inbox notes 00a53d9968, 6272351d99, 83c016b4f8, 8af8bff33f, e6e84d83e8 and eb9350103a.
Also found by searching
- duql session stage gives nondeterministic sessions with equal timestamps
- how should the sessionize gap be measured with durations and time units
- how do I lower a duql sessions stage onto an existing window kernel
- sessionize dftu.frame.window stable sort order index end column time_value
- how does the duql session stage compute gaps and ordering of rows?
- implement sessionize in duql with gap and max, which kernel to reuse?
- session stage with end column span and null time handling design
- field named session conflicts with keyword in duql, contextual keywords gap max as