st_overlaps function
Applies to: Databricks SQL
Databricks Runtime 19 and above
Lakehouse//RT
This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types.
Returns true if the two input GEOMETRY values overlap each other.
Syntax
st_overlaps ( geo1, geo2 )
Arguments
geo1: The firstGEOMETRYvalue.geo2: The secondGEOMETRYvalue.
Returns
A value of type BOOLEAN, indicating whether the two input GEOMETRY values overlap each other.
Two geometries overlap if all of the following hold:
- They have the same topological dimension.
- The intersection of their interiors has that same topological dimension.
- Neither geometry covers the other.
Geometries of different topological dimensions never overlap.
The function returns false if any of the inputs is empty.
The function does not support geometry collections.
For more details and the formal definition, see the Overlaps predicate in the DE-9IM matrix definition.
The function returns NULL if any of the inputs is NULL.
Error conditions
- If any of the input geometries is a geometry collection, the function returns ST_INVALID_ARGUMENT.INVALID_TYPE.
- If the input geometries do not have the same SRID value, the function returns ST_DIFFERENT_SRID_VALUES.
Examples
-- Returns true for two polygons that share part of their interiors.
> SELECT st_overlaps(st_geomfromtext('POLYGON((0 0,0 5,5 5,5 0,0 0))'),st_geomfromtext('POLYGON((3 3,3 9,9 9,9 3,3 3))'));
true
-- Returns false because the first polygon covers the second.
> SELECT st_overlaps(st_geomfromtext('POLYGON((0 0,0 5,5 5,5 0,0 0))'),st_geomfromtext('POLYGON((3 3,3 5,5 5,5 3,3 3))'));
false
-- Returns true for two multipoints that share some, but not all, of their points.
> SELECT st_overlaps(st_geomfromtext('MULTIPOINT(0 0,1 1,2 2)'),st_geomfromtext('MULTIPOINT(1 1,3 3,4 4)'));
true