Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately
Date
Msg-id 398522.1741541265@sss.pgh.pa.us
Whole thread Raw
In response to Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately
List pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Sat, Mar 8, 2025 at 12:50 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> For a shorter fix
>> When multiple window functions are used, all the window functions
>> having syntactically equivalent PARTITION BY and ORDER BY clauses
>> in their window definitions are guaranteed to see the same
>> ordering of the input rows, even if the ORDER BY does not uniquely
>> determine the ordering.

> WFM, the key point is removing the problematic wording and I do find this
> reads better in the end.
> However, I'm having trouble understanding the purpose of the word
> "syntactically" here.  Or even using the "clauses" at all.  Why not:

> "When multiple window functions are used, all the window functions having
> the same partitioning and ordering expressions in their window definitions
> are guaranteed to see the same ordering of the input rows, even if
> the ordering is not deterministic."

Sure, we can lose "syntactically" --- it's probably not even strictly
correct anyway, given that what we really look for is equal() parsed
expression trees.  By the same token though, I don't love "same"
here, because what is "same"?  In particular, in your phrasing
it's not clear whether "PARTITION BY foo" and "ORDER BY foo"
are considered equivalent for this purpose.  So let's go with
my wording less the "syntactically".

            regards, tom lane



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Error from array_agg when table has many rows
Next
From: "David G. Johnston"
Date:
Subject: Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately