Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: Databricks Runtime 17.1 and above
Important
This feature is in Public Preview.
Returns the point-wise union of all the geometries in the column, or NULL
if the column is zero rows, or contains only NULL
values.
Syntax
st_union_agg ( geoCol )
Arguments
geoCol
: A column ofBINARY
,GEOMETRY
, orSTRING
values representing geometry objects.
Returns
A value of type GEOMETRY
, representing the point-wise union of all geometries in the column.
The output GEOMETRY
is always two-dimensional.
The function returns NULL
if the column has zero rows or contains only NULL
values.
Error conditions
- If the input is
GEOMETRY
and geometries have different SRID values, the function returns ST_DIFFERENT_SRID_VALUES.
Examples
-- Returns union of multiple geometries from column.
> SELECT st_astext(st_union_agg(st_geomfromtext(*))) FROM (SELECT * FROM VALUES('POINT(-5 -5)'),('MULTIPOINT(1 2,8 8,5 9,-7 -7,EMPTY)'),('MULTILINESTRING(EMPTY,(5 5,9 9),(9 9,15 15))'),('POLYGON((0 0,10 0,10 10,0 10,0 0))'))
GEOMETRYCOLLECTION(MULTIPOINT((-7 -7),(-5 -5)),LINESTRING(10 10,15 15),POLYGON((0 0,10 0,10 10,0 10,0 0)))
-- Returns NULL for empty result set.
> SELECT st_union_agg(st_geomfromtext(geom)) FROM (SELECT 'POINT(1 1)' as geom WHERE false)
NULL