Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Christopher Inokuchi <cinokuchi@gmail.com>,
Greg Sabino Mullane <htamfids@gmail.com>,
pgsql-bugs@lists.postgresql.org
Date: 2025-03-09T17:27:45Z
Lists: 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
Commits
-
Doc: improve description of window function processing.
- 6841118216ef 13.21 landed
- e7d29d1fac82 14.18 landed
- 2db974e40df6 15.13 landed
- 778f9dd0d2aa 16.9 landed
- 0f27bd14e480 17.5 landed
- 9f87e2593feb 18.0 landed