Re: Request for Patch Feedback: Lag & Lead Window Functions Can Ignore Nulls

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Nicholas White <n(dot)j(dot)white(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Troels Nielsen <bn(dot)troels(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Request for Patch Feedback: Lag & Lead Window Functions Can Ignore Nulls
Date: 2013-06-28 17:26:40
Message-ID: CA+Tgmob3=9JQk3htBC0FAFwfwnkJ3ww5H0GX-KgboCFz5OOAjA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 28, 2013 at 12:29 PM, Nicholas White <n(dot)j(dot)white(at)gmail(dot)com> wrote:
>> This patch will need to be rebased over those changes
>
> See attached -

Thanks. But I see a few issues...

+ [respect nulls]|[ignore nulls]

You fixed one of these but missed the other.

<replaceable class="parameter">default</replaceable> are evaluated
with respect to the current row. If omitted,
<replaceable class="parameter">offset</replaceable> defaults to 1 and
- <replaceable class="parameter">default</replaceable> to null
+ <literal>IGNORE NULLS</> is specified then the function will
be evaluated
+ as if the rows containing nulls didn't exist.
</entry>
</row>

This looks like you dropped a line during cut-and-paste.

+ null_values = (Bitmapset *) WinGetPartitionLocalMemory(
+ winobj,
+ BITMAPSET_SIZE(words_needed));
+ Assert(null_values);

This certainly seems ugly - isn't there a way to accomplish this
without having to violate the Bitmapset abstraction?

+ * A slight edge case. Consider:
+ *
+ * A | lag(A, 1)
+ * 1 |
+ * 2 | 1
+ * | ?

pgindent will reformat this into oblivion. Use ----- markers around
the comment block as done elsewhere in the code where this is an
issue, or don't use ASCII art.

I haven't really reviewed the windowing-related code in depth; I
thought Jeff might jump back in for that part of it. Jeff, is that
something you're planning to do?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2013-06-28 17:28:35 Re: Department of Redundancy Department: makeNode(FuncCall) division
Previous Message Claudio Freire 2013-06-28 17:26:31 Re: [RFC] Minmax indexes