Closed jjcfrancisco closed 5 months ago
Hi! Thanks for raising this issue!
ST_Collect
will collect a single list value of geometries into one geometry. Think of it as collecting horizontally. What you want to do is collect vertically over multiple rows. This doesn't work if you just wrap it in square brackets because essentially you are just creating a single element list for each row. What you want to do is first aggregate multiple rows into a single list and then call st_collect
on that. You can use the list()
aggregate function to do so:
E.g.
SELECT ST_AsText(ST_LineMerge(ST_Collect(list(geom)))) AS all
Hi @Maxxen, this is great.
This is a question for another place but I am intrigued to know why DuckDB
(as a choice?) differs slightly to Postgres in the way some queries are formed.
In this case it's just because writing an aggregate function to collect an unknown amount of geometries is more difficult than if you just get all of them up front in a list. But we could of course hide this from the user by adding a macro that does the st_collect(list(geom))
internally.
I would be intrigued to know what the community at large thinks of this. Subjectively, hiding it by adding a macro it'd remove ambiguity for the user because realistically speaking, a lot of people consult PostGIS' documentation or are familiar with their workflow and expect similar behaviour in DuckDB.
I am looking to join a column of linestrings but I am unable. For comparison (and clarity) this is what I do in
PostGIS
:In
DuckDB
, if I have a similar table and use thisSELECT
statement...I get this error:
I tried to wrap the
geom
in square brackets but I get all the geometries back (no merging happens)Interestingly, this works:
But I explicitly want to do it from a column in an existing table.