Share via


st_union function

Applies to: check marked yes Databricks SQL check marked yes 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-set union of the two input GEOMETRY values as a 2D geometry.

Syntax

st_union ( geo1, geo2 )

Arguments

  • geo1: The first GEOMETRY value.
  • geo2: The second GEOMETRY value.

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

Examples

-- 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))