Re: [PATCH] GROUP BY ALL - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: [PATCH] GROUP BY ALL
Date
Msg-id 58f201ad-f2c8-4a25-b40f-213dbf7e75b7@eisentraut.org
Whole thread
In response to Re: [PATCH] GROUP BY ALL  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: [PATCH] GROUP BY ALL
List pgsql-hackers
On 14.04.26 13:21, Peter Eisentraut wrote:
> The handling of window functions by GROUP BY ALL is a semi-open-item.
> 
> The code in transformGroupClause() currently says:
> 
>      /*
>       * Likewise, TLEs containing window functions are not okay to add
>       * to GROUP BY.  At this writing, the SQL standard is silent on
>       * what to do with them, but by analogy to aggregates we'll just
>       * skip them.
>       */
>      if (pstate->p_hasWindowFuncs &&
>          contain_windowfuncs((Node *) tle->expr))
>          continue;
> 
> The wording of the SQL standard currently does not address that at all 
> (but we could fix it), which would mean that a window function ends up 
> in the GROUP BY ALL expansion by default.
> 
> Personally, I don't understand what the meaning of this should be. 
> Aggregates relate to grouping, but window functions are a different 
> processing phase, so that do they have to do with grouping?

At the most recent SQL standard meeting, I had this issue addressed, and 
the handling of window functions in GROUP BY ALL is now specified to 
work like PostgreSQL already works.  I propose the attached patch that 
updates the code comment about that, and also makes the documentation 
more specific that we are only talking about aggregate functions and 
window functions referring to the same query level, which is another 
thing the original specification was silent about but which has since 
been fixed.  The two SQL change proposal papers are attached for reference.


Attachment

pgsql-hackers by date:

Previous
From: Jakub Wartak
Date:
Subject: Re: Adding basic NUMA awareness
Next
From: Álvaro Herrera
Date:
Subject: Re: DROP INVALID INDEXES command