I want to make a geometry array or a new geometry which is combination of few other geometries. I have one table with id column, geometry column and start_cls column. So, I want to group my ids and geometries based on start_cls value. So, I executed following query.
SELECT array_agg(gid), st_union(geom), start_cls FROM public.edge_table_original group by start_cls limit 20
But in most of the cases, the union of geometry is giving null. I also tried with array_agg(geom) instead of st_union(geom). But the result is same. And I observed when the number of elements in the array is small, then it is giving the value of array_agg and st_union. But if the number of elements are significantly high, then it is not giving. May be there are some character limit problem. How to overcome this problem? I have added the screen shot of data output.
I also checked ST_AsTWKB. But this function returns bytea. But I need geometry or geometry output. As I shall use st_makeline on this geometry or geometry.