Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options

Oliver Ford <ojford@gmail.com>

From: Oliver Ford <ojford@gmail.com>
To: Tatsuo Ishii <ishii@postgresql.org>
Cc: vik@postgresfriends.org, pgsql-hackers@postgresql.org, tgl@sss.pgh.pa.us, andrew@tao11.riddles.org.uk, david@fetter.org, krasiyan@gmail.com
Date: 2025-01-17T16:43:29Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix coding style with "else".

  2. Fix multi WinGetFuncArgInFrame/Partition calls with IGNORE NULLS.

  3. Fix Coverity issue reported in commit 2273fa32bce.

  4. Use ereport rather than elog in WinCheckAndInitializeNullTreatment.

  5. Avoid uninitialized-variable warnings from older compilers.

  6. Fix Coverity issues reported in commit 25a30bbd423.

  7. Improve EXPLAIN's display of window functions.

  8. Automatically generate node support functions

Attachments

On Thu, Sep 12, 2024 at 2:41 AM Tatsuo Ishii <ishii@postgresql.org> wrote:
>
> It seems you allow to use IGNORE NULLS for all window functions. If
> the case, you should explicitely stat that in the docs. Otherwise
> users will be confused because;

The latest version restricts it to lag, lead, first_value, last_value,
and nth_value. We can extend it in a subsequent patch if there's
demand?

> I take a look at the patch and noticed that following functions have
> no comments on what they are doing and what are the arguments. Please
> look into other functions in nodeWindowAgg.c and add appropriate
> comments to those functions.

Latest version has more comments and should be in the standard coding style.

> I also notice that you have an array in memory which records non-null
> row positions in a partition. The position is represented in int64,
> which means 1 entry consumes 8 bytes. If my understanding is correct,
> the array continues to grow up to the partition size. Also the array
> is created for each window function (is it really necessary?). I worry
> about this because it might consume excessive memory for big
> partitions.

It's an int64 because it stores the abs_pos/mark_pos which are int64.
Keeping an array for each function is needed for the mark optimization
to work correctly.