Postgres Aggregate Into Arraylist Length Function In R