Re: proposal for 8.5, listagg aggregate function, WIP patch - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal for 8.5, listagg aggregate function, WIP patch
Date
Msg-id 162867790912251410i1a54ad25ib2757dd714697e@mail.gmail.com
Whole thread Raw
In response to Re: proposal for 8.5, listagg aggregate function, WIP patch  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
2009/12/25 Tom Lane <tgl@sss.pgh.pa.us>:
> Pavel Stehule <pavel.stehule@gmail.com> writes:
>> I propose a new aggregate function - listagg. This function
>> concatenate values to string. If this function is used with two
>> parameters, then second parameter is used as delimiter. NULL input
>> values are ignored like other aggregates. If all values are NULL, then
>> result is NULL. When delimiter is omitted, then values are
>> concatenated without any delimiter.
>
> The main objection I have to this proposal is the name: listagg seems
> pretty horrid.  It's got nothing to do with lists, and it doesn't even
> attempt to be consistent with other existing function names.

It is list - on application level - without arrays - was used list of
values separated by comma. I don't have a experience with Oracle. But
I know this term in this meaning from MSSQL.

>
> I can see a couple of different approaches that might make sense
> for choosing a better name.  One is "something_to_string", though
> I'm not sure what "something" should be --- maybe "rows" or "set"?
> The other approach is to name it something based on concat() on the
> grounds that it's a form of concatenation, and we do have "concat"
> in the standard in the guise of XMLCONCAT.  For instance there's some
> case for concat_agg() by analogy to array_agg(); though personally
> I think array_agg() is a horrid name too and not one of the SQL
> committee's better efforts.

I don't know, who though up named this function in Oracle. This
functionality is known as "listagg" (Oracle) or "group_concat"
(MySQL). I don't thing we need a third name for it. group_concat has
enhanced syntax:

GROUP_CONCAT([DISTINCT] expr [,expr ...]            [ORDER BY {unsigned_integer | col_name | expr}                [ASC
|DESC] [,col_name ...]]            [SEPARATOR str_val]) 

there are keyword SEPARATOR. Oracle's syntax is nearer to standard
PostgreSQL's syntax

http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/functions087.htm

But Oracle has own syntax too. After some experience today, I see some
advantage Oracle's syntax over standard :).

This function isn't standardised now, so we can use any name. I vote
name used in Oracle db.

Regards
Pavel Stehule




>
>                        regards, tom lane
>


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: proposal for 8.5, listagg aggregate function, WIP patch
Next
From: Robert Haas
Date:
Subject: Re: creating index names automatically?