Re: ANY_VALUE aggregate - Mailing list pgsql-hackers

From Robert Haas
Subject Re: ANY_VALUE aggregate
Date
Msg-id CA+TgmoaKUOFGLDFeOOmxR7Z1KbLZ5fYWEMoXvx0hGAY4Op8OnQ@mail.gmail.com
Whole thread Raw
In response to Re: ANY_VALUE aggregate  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, Dec 5, 2022 at 1:04 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
> > Can we please add "first_value" and "last_value" if we are going to add
> > "some_random_value" to our library of aggregates?
>
> First and last according to what ordering?  We have those in the
> window-aggregate case, and I don't think we want to encourage people
> to believe that "first" and "last" are meaningful otherwise.
>
> ANY_VALUE at least makes it clear that you're getting an unspecified
> one of the inputs.

I have personally implemented first_value() and last_value() in the
past in cases where I had guaranteed the ordering myself, or didn't
care what ordering was used. I think they're perfectly sensible. But
if we don't add them to core, at least they're easy to add in
user-space.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ANY_VALUE aggregate
Next
From: Andres Freund
Date:
Subject: Re: Using WaitEventSet in the postmaster