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

From: Nicholas White <n(dot)j(dot)white(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Troels Nielsen <bn(dot)troels(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(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" <pgsql-hackers(at)postgresql(dot)org>
Subject: Request for Patch Feedback: Lag & Lead Window Functions Can Ignore Nulls
Date: 2013-07-01 22:20:40
Message-ID: CA+=vxNbcnZxDqVg4EX8oqMyFxU5XV2ron-MaE7_PZ8V-W-gDYA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> pg_get_viewdef() needs to be updated

Ah, good catch - I've fixed this in the attached. I also discovered that
there's a parent-child hierarchy of WindowDefs (using relname->name), so
instead of cloning the WindowDef (in parse_agg.c) if the frameOptions are
different (e.g. by adding the ignore-nulls flag) I create a child of the
WindowDef and override the frameOptions. This has the useful side-effect of
making pg_get_viewdef work as expected (the previous iteration of the patch
produced a copy of the window definintion, not the window name, as it was
using a nameless clone), although the output has parentheses around the
view name:

> lag(i.i, 2) IGNORE NULLS OVER (w) AS lagged_by_2

I've updated the test cases accordingly. Thanks -

Nick

Attachment Content-Type Size
lead-lag-ignore-nulls.patch application/octet-stream 33.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2013-07-01 22:27:06 Re: pg_ctl and -h/help
Previous Message Luis Carvalho 2013-07-01 22:15:15 PL/Lua (was: plpython implementation)