Re: ON EMPTY clause for aggregate and window functions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: ON EMPTY clause for aggregate and window functions
Date
Msg-id 506576.1790617244@sss.pgh.pa.us
Whole thread
In response to Re: ON EMPTY clause for aggregate and window functions  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Thu, Sep 24, 2026 at 9:18 AM Jeevan Chalke <
> jeevan.chalke@enterprisedb.com> wrote:
>> It only accepts ON EMPTY on sum() and product(), the two aggregates the
>> standard actually defines this for. At parse time, once we know the
>> call is sum() or product(), it is just rewritten to
>> COALESCE(sum(expr), default). Nothing else changes:

> I can't get excited about supporting this syntax for just 2 aggregates and
> nothing else.

Yeah, that would be totally not in keeping with this project's usual
attitudes about extensibility.

"Rewrite at parse time" is an ugly hack anyway, because then view
dumps and so forth expose the implementation.  It'd need to be
done later.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: ON EMPTY clause for aggregate and window functions
Next
From: Vik Fearing
Date:
Subject: Re: ON EMPTY clause for aggregate and window functions