v.21.4Experimental Features
Support RANGE OFFSET Frame for Floating Point Types in Window Functions
SupportRANGE OFFSETframe (for window functions) for floating point types. ImplementlagInFrame/leadInFramewindow functions, which are analogous tolag/lead, but respect the window frame. They are identical when the frame isbetween unbounded preceding and unbounded following. This closes #5485. #21895 (Alexander Kuzmenkov).
Why it matters
This feature solves the problem of applying offset-based window functions within a specifiedRANGE OFFSET frame for floating point data, allowing for more precise and frame-aware calculations. It improves the expressiveness and correctness of window functions when working with floating point range frames instead of default row-based or unbounded frames.How to use it
Users can apply this feature by using theRANGE OFFSET clause in window frames on floating point columns. They can also use the newly introduced window functions lagInFrame and leadInFrame in their queries, which will operate respecting the defined window frame. For example:SELECT
some_column,
lagInFrame(some_value) OVER (ORDER BY timestamp RANGE OFFSET 10 AS FLOAT PRECEDING)
FROM tableThis usage ensures that the lag/lead calculation only considers rows within the specified floating point range frame.