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

From Robert Haas
Subject Re: ON EMPTY clause for aggregate and window functions
Date
Msg-id CA+TgmoYfZW9y_T8A1nykRUcvJ2FQtMpBjgkq=+TCdq0-odF4=w@mail.gmail.com
Whole thread
In response to Re: ON EMPTY clause for aggregate and window functions  (Isaac Morland <isaac.morland@gmail.com>)
Responses Re: ON EMPTY clause for aggregate and window functions
List pgsql-hackers
On Sat, Sep 12, 2026 at 9:19 AM Jeevan Chalke
<jeevan.chalke@enterprisedb.com> wrote:
> ON EMPTY is now implemented as exactly:
>
>     agg(args, default ON EMPTY)  ==  COALESCE(agg(args), default)
>
> for both plain and window aggregates: compute the aggregate's ordinary
> result exactly as without ON EMPTY, and substitute the default only if that
> result is NULL. No new expression-evaluation step, no per-row bookkeeping,
> and no restriction on partial/parallel aggregation.

This seems pretty useless -- the new syntax is more work for us to
maintain, and doesn't really add any value over just using COALESCE.

To be clear, I expect to lose this argument on the grounds that
apparently this syntax is in the spec and therefore we ought to
support it. But I don't understand why the spec -- or we -- should
spend time inventing new ways to spell existing behaviors. That just
seems confusing (and this particular choice of syntax seems
extra-confusing).

--
Robert Haas



pgsql-hackers by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: pgoutput: schema cache cleanup after streamed 2PC
Next
From: Manuel Reyes Bravo
Date:
Subject: Re: pgsql: Revert online data checksum transitions