Implement <null treatment> for window functions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Implement <null treatment> for window functions

Vik Fearing-6
This feature adds RESPECT NULLS and IGNORE NULLS syntax to several
window functions, according to the SQL Standard.

Unlike the last time this was attempted[1], my version does not hardcode
the spec's list of functions that this applies to.  Instead, it accepts
it for all true window functions (that is, it does not apply to
aggregates acting as window functions).

This patch also does not attempt to solve the FROM LAST problem.  That
remains unimplemented.

For the CREATE FUNCTION syntax, I used TREAT NULLS so as to avoid
creating new keywords.

The second patch adds some new window functions in order to test that
the null treatment works correctly for cases that aren't covered by the
standard functions but that custom functions might want to use.  It is
*not* intended to be committed; I am only submitting the first patch for
inclusion in core.

This is based off of 324435eb14.

[1]
https://www.postgresql.org/message-id/CAGMVOdsbtRwE_4%2Bv8zjH1d9xfovDeQAGLkP_B6k69_VoFEgX-A%40mail.gmail.com
--
Vik Fearing

0001-implement-null-treatment-for-window-functions.patch (65K) Download Attachment
0002-new-window-functions-to-aid-testing.patch (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Implement <null treatment> for window functions

Dagfinn Ilmari Mannsåker
Vik Fearing <[hidden email]> writes:

> The second patch adds some new window functions in order to test that
> the null treatment works correctly for cases that aren't covered by the
> standard functions but that custom functions might want to use.  It is
> *not* intended to be committed; I am only submitting the first patch for
> inclusion in core.

Would it make stense to add them as a test extension under
src/test/modules/?

- ilmari
--
"A disappointingly low fraction of the human race is,
 at any given time, on fire." - Stig Sandbeck Mathisen


Reply | Threaded
Open this post in threaded view
|

Re: Implement <null treatment> for window functions

Daniel Gustafsson
In reply to this post by Vik Fearing-6
> On 30 Jun 2020, at 15:54, Vik Fearing <[hidden email]> wrote:

> This feature adds RESPECT NULLS and IGNORE NULLS syntax to several
> window functions, according to the SQL Standard.

This fails compilation due to a compiler warning in WinGetFuncArgInPartition
and WinGetFuncArgInFrame (same warning in both):

nodeWindowAgg.c: In function ‘WinGetFuncArgInPartition’:
nodeWindowAgg.c:3274:10: error: ‘step’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   relpos += step;
          ^
This was with GCC in the Travis build, the Windows build passed and so does
clang locally for me.

cheers ./daniel