Hi,
You can probably do this with queryDef, defining the groupBy independently of the <select/> and enabling unknown sql functions/adding array_agg function. If not it's just a couple lines extra to spool the results into a map then update the temp schema with '{' + map[k].join(',') + '}'.
Thanks,
-Jon