Re: add more frame types in window functions (ROWS) - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: add more frame types in window functions (ROWS)
Date
Msg-id 87y6m8najw.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to add more frame types in window functions (ROWS)  (Hitoshi Harada <umi.tanuki@gmail.com>)
Responses Re: add more frame types in window functions (ROWS)
Re: add more frame types in window functions (ROWS)
Re: add more frame types in window functions (ROWS)
List pgsql-hackers
Hi, I've started reviewing your patch.

I've already found some things that need work:
- missing _readWindowFrameDef function (all nodes that are output  from parse analysis must have both _read and _out
functions, otherwise views can't work)
 
- the A_Const nodes should probably be transformed to Const nodes in  parse analysis, since A_Const has no _read/_out
functions,which  means changing the corresponding code in the executor.
 

(A question here: the spec allows (by my reading) the use of
parameters in the window frame clause, i.e. BETWEEN $1 PRECEDING AND
$2 FOLLOWING.  Wouldn't it therefore make more sense to treat the
values as Exprs, albeit very limited ones, and eval them at startup
rather than assuming we know the node type and digging down into it
all over the place?)

You can see the problem here if you do this:

create view v as select i,sum(i) over (order by i rows between 1 preceding and 1 following)   from
generate_series(1,10)i;
 
select * from v;

(A regression test for this would probably be good, which reminds me that
I need to add one of those myself in the aggregate order by stuff.)

Also, you're going to need to do some work in ruleutils.c
(get_rule_windowspec) in order to be able to deparse your new frame
definitions.

I'll continue reviewing the stuff that does work, so I'm not marking this
as "waiting for author" yet.

-- 
Andrew (irc:RhodiumToad)


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Inspection of row types in pl/pgsql and pl/sql
Next
From: Tom Lane
Date:
Subject: Re: add more frame types in window functions (ROWS)