You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Vladimir Sitnikov <si...@gmail.com> on 2014/06/19 09:18:11 UTC
window functions
Hi,
Recently I've updated implementation of window functions to support RANGE,
expr PRECEDING/FOLLOWING, UNBOUNDED FOLLOWING [1].
Please let me know if you have any objections to getting it merged.
The implementation is optimized for the cases when lower bound stays intact
and the upper bound moves down: "unbounded preceding and current row" and
"unbounded preceding and unbounded following" cases.
For instance, count(*) over () is infinite times faster now as it computes
the aggregate only once, and then it just reuses the result.
In fact, count(non_nullable), row_number(), first_value(), and last_value()
are O(1): it's just index arithmetic to compute the value.
Range windows use binary search to find out the lower/upper bounds.
If the window becomes invalid (e.g. upper bound is less than lower bound),
it is assumed the window is empty (no exception).
Regular aggregate implementation was altered a bit: if the user-defined
function provides non-static init/add/result methods, then only one
instance is created per grouping key (init, add, and result methods are
invoked on the same object instance).
1: https://github.com/julianhyde/optiq/pull/293
--
Regards,
Vladimir Sitnikov
Re: window functions
Posted by Julian Hyde <ju...@hydromatic.net>.
Thanks, I'm pulling onto master right now. Really nice work, Vladimir.
Then I plan to pull my https://github.com/julianhyde/optiq/commits/optiq-299
branch.
A lot of changes in those branches, so 1 hour from now would be a good time
to pull from master.
On Thu, Jun 19, 2014 at 12:18 AM, Vladimir Sitnikov <
sitnikov.vladimir@gmail.com> wrote:
> Hi,
>
> Recently I've updated implementation of window functions to support RANGE,
> expr PRECEDING/FOLLOWING, UNBOUNDED FOLLOWING [1].
>
> Please let me know if you have any objections to getting it merged.
>
> The implementation is optimized for the cases when lower bound stays intact
> and the upper bound moves down: "unbounded preceding and current row" and
> "unbounded preceding and unbounded following" cases.
>
> For instance, count(*) over () is infinite times faster now as it computes
> the aggregate only once, and then it just reuses the result.
> In fact, count(non_nullable), row_number(), first_value(), and last_value()
> are O(1): it's just index arithmetic to compute the value.
>
> Range windows use binary search to find out the lower/upper bounds.
>
> If the window becomes invalid (e.g. upper bound is less than lower bound),
> it is assumed the window is empty (no exception).
>
> Regular aggregate implementation was altered a bit: if the user-defined
> function provides non-static init/add/result methods, then only one
> instance is created per grouping key (init, add, and result methods are
> invoked on the same object instance).
>
> 1: https://github.com/julianhyde/optiq/pull/293
>
> --
> Regards,
> Vladimir Sitnikov
>