Re: ANY_VALUE aggregate
David G. Johnston <david.g.johnston@gmail.com>
From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Pantelis Theodosiou <ypercube@gmail.com>
Cc: Vik Fearing <vik@postgresfriends.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-12-07T13:36:04Z
Lists: pgsql-hackers
On Wed, Dec 7, 2022 at 1:58 AM Pantelis Theodosiou <ypercube@gmail.com> wrote: > On Tue, Dec 6, 2022 at 4:57 AM David G. Johnston > <david.g.johnston@gmail.com> wrote: > ... > > > > > > I'm referring to the query: > > > > select any_value(v order by v) from (values (2),(1),(3)) as vals (v); > > // produces 1, per the documented implementation-defined behavior. > > > > Someone writing: > > > > select any_value(v) from (values (2),(1),(3)) as vals (v) order by v; > > > > Is not presently, nor am I saying, promised the value 1. > > > > Shouldn't the 2nd query be producing an error, as it has an implied > GROUP BY () - so column v cannot appear (unless aggregated) in SELECT > and ORDER BY? > Right, that should be written as: select any_value(v) from (values (2),(1),(3) order by 1) as vals (v); (you said SELECT; the discussion here is that any_value is going to be added as a new aggregate function) David J.
Commits
-
Implement ANY_VALUE aggregate
- 2ddab010c277 16.0 landed
-
Generalize ri_RootToPartitionMap to use for non-partition children
- fb958b5da86d 16.0 cited