microo8 / plgo

easily create postgresql extensions in golang; moved to gitlab.com/microo8/plgo
292 stars 23 forks source link

Custom aggregate support #16

Open sachaarbonel opened 6 years ago

sachaarbonel commented 6 years ago

Hi @microo8 I was searching how to apply my functions on an entire column and not on an array I found useful articles about custom aggregations:

Do you think it could be tricky to create a type Aggregate and automate the rewrite of the functions in the sql file ?

microo8 commented 6 years ago

I can take a look at custom aggregates and figure out what to do.

But for now you can do something like this:

select myfunction(array_agg(column)) from table
sachaarbonel commented 6 years ago

Ok thank's a lot I thought it could improve on performances to use aggregations

onshorechet commented 5 years ago

This may already be possible by writing normal functions in go and exposing them using plgo to postgres. Then use "create aggregate.." and compose in those functions.

"A simple aggregate function is made from one or two ordinary functions: a state transition function sfunc, and an optional final calculation function ffunc"