Can I use a subquery?
postgres=# select ar[1], ar[2] from (select string_to_array('ab c', ' ') ar) as sq; ar | ar ----+---- a | b (1 row)
This still requires you to explicitly retrieve each column (as you already did). If there are more elements in the array than are extracted, they will be lost, and if there are fewer, then the missing columns will be only NULL .
EDIT: I think I would wrap it all in a subquery; the internal subquery generates the necessary rows, and the external selection issues an internal query in the necessary columns:
SELECT subquery1.a, subquery1.b, subquery1.c, myfunction_result[1], myfunction_result[2] FROM ( SELECT table1.a, table1.b, table1.c, MyFunction(table1.a, table1.b, table1.c) as myfunction_result FROM table1 INNER JOIN table2 using(b) WHERE ... GROUP BY table1.a, table1.b, table1.c ) AS subquery1;
Internal and external selection will correctly correlate table1 links.
SingleNegationElimination
source share