Re: ON EMPTY clause for aggregate and window functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>
Subject: Re: ON EMPTY clause for aggregate and window functions
Date: 2026-09-28 17:40:44
Message-ID: 506576.1790617244@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Thu, Sep 24, 2026 at 9:18 AM Jeevan Chalke <
> jeevan(dot)chalke(at)enterprisedb(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vik Fearing 2026-09-28 17:53:18 Re: ON EMPTY clause for aggregate and window functions
Previous Message Robert Haas 2026-09-28 17:36:47 Re: ON EMPTY clause for aggregate and window functions