Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options
Date
Msg-id CAKFQuwamWORs6WJ+ftCRUC1yh8k-b0Ny5G5ryD7_m9u+B94SHA@mail.gmail.com
Whole thread Raw
In response to Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options  (Tatsuo Ishii <ishii@postgresql.org>)
Responses Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options
List pgsql-hackers
On Wednesday, September 11, 2024, Tatsuo Ishii <ishii@postgresql.org> wrote:

test=# SELECT row_number() IGNORE NULLS OVER w FROM t1 WINDOW w AS (ORDER BY i);
 row_number
------------
          1
          2
(2 rows)

The t1 table only contains NULL rows. By using IGNORE NULLS, I think
it's no wonder that a user expects 0 rows returned, if there's no
mention in the docs that actually IGNORE NULLS/RESPECT NULLS are just
ignored in some window functions.

My nieve understanding of the nulls treatment is computations are affected, therefore a zero-argument function is incapable of abiding by this clause (it should error…).  Your claim that this should somehow produce zero rows confuses me on two fronts.  One, window function should be incapable of affecting how many rows are returned.  The query must output two rows regardless of the result of the window expression (it should at worse produce the null value).  Two, to produce said null value you have to be ignoring the row due to the order by clause seeing a null.  But the order by isn’t part of the computation.

David J.

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Opinion poll: Sending an automated email to a thread when it gets added to the commitfest
Next
From: Amit Langote
Date:
Subject: Re: json_query conditional wrapper bug