From: | Jacob Champion <jchampion(at)timescale(dot)com> |
---|---|
To: | Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> |
Cc: | pgsql-hackers(at)postgresql(dot)org, vik(at)postgresfriends(dot)org |
Subject: | Re: Row pattern recognition |
Date: | 2023-07-19 16:30:40 |
Message-ID: | 07214b3a-5893-f6ce-ef55-0e5d24c94925@timescale.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
Thanks for working on this! We're interested in RPR as well, and I've
been trying to get up to speed with the specs, to maybe make myself
useful.
On 6/27/23 17:58, Tatsuo Ishii wrote:
> Yes. (I think the standard calls the window frame as "full window
> frame" in context of RPR to make a contrast with the subset of the
> frame rows restricted by RPR. The paper I refered to as [2] claims
> that the latter window frame is called "reduced window frame" in the
> standard but I wasn't able to find the term in the standard.)
19075-5 discusses that, at least; not sure about other parts of the spec.
> Maybe an insane idea but what about rewriting MATCH_RECOGNIZE clause
> into Window clause with RPR?
Are we guaranteed to always have an equivalent window clause? There seem
to be many differences between the two, especially when it comes to ONE
ROW/ALL ROWS PER MATCH.
--
To add onto what Vik said above:
>> It seems RPR in the standard is quite complex. I think we can start
>> with a small subset of RPR then we could gradually enhance the
>> implementation.
>
> I have no problem with that as long as we don't paint ourselves into a
> corner.
To me, PATTERN looks like an area where we may want to support a broader
set of operations in the first version. The spec has a bunch of
discussion around cases like empty matches, match order of alternation
and permutation, etc., which are not possible to express or test with
only the + quantifier. Those might be harder to get right in a v2, if we
don't at least keep them in mind for v1?
> +static List *
> +transformPatternClause(ParseState *pstate, WindowClause *wc, WindowDef *windef)
> +{
> + List *patterns;
My compiler complains about the `patterns` variable here, which is
returned without ever being initialized. (The caller doesn't seem to use
it.)
> +-- basic test using PREV
> +SELECT company, tdate, price, rpr(price) OVER w FROM stock
> + WINDOW w AS (
> + PARTITION BY company
> + ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
> + INITIAL
> + PATTERN (START UP+ DOWN+)
> + DEFINE
> + START AS TRUE,
> + UP AS price > PREV(price),
> + DOWN AS price < PREV(price)
> +);
nitpick: IMO the tests should be making use of ORDER BY in the window
clauses.
This is a very big feature. I agree with you that MEASURES seems like a
very important "next piece" to add. Are there other areas where you
would like reviewers to focus on right now (or avoid)?
Thanks!
--Jacob
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-07-19 16:47:48 | Re: psql: Add role's membership options to the \du+ command |
Previous Message | Tristan Partin | 2023-07-19 16:16:34 | Re: Support to define custom wait events for extensions |