st_contains
function
Applies to: Databricks SQL
Databricks Runtime 17.1 and above
Preview
This feature is in Public Preview.
注記
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 first GEOMETRY
contains the second GEOMETRY
.
Syntax
st_contains ( geoExpr1, geoExpr2 )
Arguments
geoExpr1
: The firstGEOMETRY
value.geoExpr2
: The secondGEOMETRY
value.
Returns
Returns true if the first geometry contains the second geometry. Currently, the expression does not support geometry collections. For more details on what it means for a geometry to contain another, see the Contains predicate in the DE-9IM matrix definition.
Error conditions
- If any of the two input geometries is a geometry collection, the function returns ST_INVALID_ARGUMENT.INVALID_TYPE.
- If the two input geometries have different SRID values, the function returns ST_DIFFERENT_SRID_VALUES.
Examples
SQL
> SELECT st_contains(st_geomfromtext('POLYGON((0 0,10 0,0 10,0 0))'),st_geomfromtext('POINT(1 1)'));
true
> SELECT st_contains(st_geomfromtext('POLYGON((0 0,10 0,0 10,0 0))'),st_geomfromtext('POINT(5 0)'));
false
> SELECT st_contains(st_geomfromtext('POLYGON((0 0,10 0,0 10,0 0))'),st_geomfromtext('POINT(5 6)'));
false