st_union function
Applies to: Databricks SQL
Databricks Runtime 17.1 and above
Lakehouse//RT
remarque
This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types.
Returns the point-set union of the two input GEOMETRY values as a 2D geometry.
Syntax
st_union ( geo1, geo2 )
Arguments
geo1: The firstGEOMETRYvalue.geo2: The secondGEOMETRYvalue.
Returns
A value of type GEOMETRY, representing the point-set union of the two input GEOMETRY values as a 2D geometry.
The SRID of the returned GEOMETRY value is the common SRID of the two input GEOMETRY values.
The function returns NULL if any of the inputs is NULL.
Error conditions
- If the input geometries do not have the same SRID value, the function returns ST_DIFFERENT_SRID_VALUES.
Examples
SQL
-- Returns union of multipoint and polygon.
> SELECT st_astext(st_union(st_geomfromtext('MULTIPOINT(EMPTY,4 3,5 6,-1 8)'),st_geomfromtext('POLYGON((0 0,10 0,0 10,0 0))')));
GEOMETRYCOLLECTION(POINT(-1 8),POINT(5 6),POLYGON((0 0,0 10,10 0,0 0)))
-- Returns union of two overlapping polygons.
> SELECT st_astext(st_union(st_geomfromtext('POLYGON((0 0,5 0,5 5,0 5,0 0))'),st_geomfromtext('POLYGON((3 3,8 3,8 8,3 8,3 3))')));
POLYGON((5 3,5 0,0 0,0 5,3 5,3 8,8 8,8 3,5 3))