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 SQL
Databricks Runtime 17.1 and above
Important
This feature is in Public Preview.
Note
This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types.
Returns the point-wise union of all the geometries in the column, or NULL if the column has zero rows, or contains only NULL values.
Syntax
st_union_agg ( geoCol )
Arguments
geoCol: A column of typeGEOMETRY, representing geometry objects.
Returns
A value of type GEOMETRY, representing the point-wise union of all GEOMETRY values 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 two
GEOMETRYvalues in the input column 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