pranadb icon indicating copy to clipboard operation
pranadb copied to clipboard

Implement window functions

Open purplefox opened this issue 3 years ago • 0 comments

We will include the sliding_window and hopping_window valued functions that can be used in the FROM clause of queries that will enable working with windows of data.

Here’s an example of a join using a window function.

select p.id, s.amount, s.customer_id from
sliding_window(sales, 10, 1) s
inner join
sliding_window(payments, 10, 1) p
on (p.customer_id = s.customer_id and p.w_end == s.w_end)

This join returns a row when there are sales and payments for the same customer in the same 10 minute window. The 10 minute windows start at 1 minute intervals.

Window functions take the table argument and enrich every row with two new columns wstart and wend which represent the start and end times of any window which contains the data.

purplefox avatar Sep 30 '21 15:09 purplefox