Re: creating a new aggregate function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Seb <spluque(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: creating a new aggregate function
Date: 2014-03-04 00:17:55
Message-ID: 20952.1393892275@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Seb <spluque(at)gmail(dot)com> writes:
> Thanks for that suggestion. It seemed as if array_agg would allow me to
> define a new aggregate for avg as follows:

> CREATE AGGREGATE avg (angle_vector)
> (
> sfunc=array_agg,
> stype=anyarray,
> finalfunc=angle_vector_avg
> );

That's not going to work, for exactly this reason:

> ERROR: cannot determine transition data type
> DETAIL: An aggregate using a polymorphic transition type must have at least one polymorphic argument.

I see no reason to use a polymorphic type here anyway ... why not just
declare the transition data type as angle_vector[] ?

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Sebastian P. Luque 2014-03-04 00:57:17 Re: creating a new aggregate function
Previous Message Seb 2014-03-04 00:07:45 Re: creating a new aggregate function