Your proposals will of course work. But they force the user to think in terms of a lower-level language.
* TUMBLE is of course simple. Before we had TUMBLE we used "GROUP BY FLOOR(…)”. * HOP is a bit more complicated, because you need to create multiple copies of each row, each going into a different group. (In your solution, joining to the UNNEST is what creates those multiple copies. But that will introduce double-counting into any other aggregate functions in the same query, so the user will need to be careful.) * You don’t mention SESSION, which is more complicated still. I don’t think it can be reduced to a simple operator. Julian > On Feb 9, 2024, at 11:30 AM, Mihai Budiu <mbu...@gmail.com> wrote: > > Hello, > > I am not sure whether this is the right place to discuss this problem, but I > don't know a better one. > > I am looking at the streaming extensions TUMBLE and HOP. I wonder why they > require multiple functions and table functions each. It looks to me like they > can be implemented in a much simpler way. > > > * > TUMBLE can in fact be a scalar function that takes a timestamp and returns a > timestamp (the start of the window). It can be just used in a SELECT > statement, like any other scalar function. > * > HOP can be in fact a scalar function that takes a timestamp and returns an > array of timestamps (the start of all the windows containing the timestamp). > It can be used in a SELECT with an UNNEST for the array. > > Then all this business about table functions and _START, _END is no longer > required. > > Thank you, > Mihai