Re: Idea: Add first() and last() aggregate functions to the main release - Mailing list pgsql-general

From Erwin Brandstetter
Subject Re: Idea: Add first() and last() aggregate functions to the main release
Date
Msg-id CAGHENJ5QVH5gRLSEBMapgYi_zAcAartu8hBmrNomnVYLez=44g@mail.gmail.com
Whole thread Raw
In response to Idea: Add first() and last() aggregate functions to the main release  (Ben Clements <benhasgonewalking@gmail.com>)
List pgsql-general
On Sat, 11 Mar 2023 at 23:38, Ben Clements <benhasgonewalking@gmail.com> wrote:
Idea/request for enhancement: 

Add the first() and last() aggregate functions to the main release (CREATE EXTENSION first_last_agg).



Reason: As a non-dba, I can’t install additional modules like first_last_agg.


For what it's worth, I support the inclusion of first() and last() in the main release. It makes queries involving multiple aggregate functions a lot simpler. Most hosted services only allow official contrib modules.
The module has been around for more than 10 years now. First on https://www.pgxn.org/dist/first_last_agg, then on https://github.com/wulczer/first_last_agg. And it's been available from apt.postgresql.org for a long time now.
Related questions pop up on Stackoverflow every now and then.
(I don't see anything related in the Postgres Todo, yet.)

The implementation in the additional module first_last_agg looks very simple and straight-forward. Might be an easy task to incorporate into mainline Postgres. But my C foo is just not good enough to judge whether the implementation is ideal.

Regards
Erwin

pgsql-general by date:

Previous
From: Ron
Date:
Subject: Re: confusion between max_standby_archive_delay, max_standby_archive_delay and max_standby_archive_delay
Next
From: Martijn de Munnik
Date:
Subject: Re: ERROR: only immutable functions supported in continuous aggregate view