ST_Union_Agg returns NULL for point inputs
- Dominant language
- Rust
- Stars
- 503
- Forks
- 61
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 90
Description
`ST_Union_Agg` returns `NULL` when aggregating point geometries, instead of the expected unioned `MULTIPOINT`. It works correctly for polygons, and `ST_Collect_Agg` works correctly for points — so the issue appears specific to `ST_Union_Agg` with point inputs.
## Reproduce
```sql
SELECT ST_AsText(ST_Union_Agg(g))
FROM (VALUES (ST_Point(0.0, 0.0)), (ST_Point(1.0, 1.0))) AS t(g);
-- actual: NULL
-- expected: MULTIPOINT((0 0),(1 1))
```
## Works as expected (for contrast)
`ST_Collect_Agg` on the same points:
```sql
SELECT ST_AsText(ST_Collect_Agg(g))
FROM (VALUES (ST_Point(0.0, 0.0)), (ST_Point(1.0, 1.0))) AS t(g);
-- MULTIPOINT((0 0),(1 1))
```
`ST_Union_Agg` on polygons (merges correctly):
```sql
SELECT ST_AsText(ST_Union_Agg(g))
FROM (VALUES
(ST_GeomFromText('POLYGON((0 0,2 0,2 2,0 2,0 0))')),
(ST_GeomFromText('POLYGON((1 1,3 1,3 3,1 3,1 1))'))
) AS t(g);
-- MULTIPOLYGON(((0 2,0 0,2 0,2 1,3 1,3 3,1 3,1 2,0 2)))
```
Only point inputs to `ST_Union_Agg` return `NULL`.
Found while writing a "Migrating from GeoPandas" dissolve example (GeoPandas `dissolve` unions each group's geometry, which for points yields a `MULTIPOINT`).
Contributor guide
Research direction
Start by running the reported ST_Union_Agg query with two point geometries, then compare it with the ST_Collect_Agg point query and the ST_Union_Agg polygon query. Trace the ST_Union_Agg entry point and its point-input handling; done means point inputs return the expected MULTIPOINT instead of NULL while the existing polygon behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100