Skip to main content

st_dwithin function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 17.1 and above

Preview

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 true if the 2D Cartesian distance between the two input GEOMETRY values is smaller than or equal to the input distance value.

Syntax

st_dwithin ( geoExpr1, geoExpr2, distanceExpr )

Arguments

  • geoExpr1: The first GEOMETRY value.
  • geoExpr2: The second GEOMETRY value.
  • distanceExpr: The distance threshold value.

Returns

A value of type BOOLEAN, indicating whether the distance of the two input GEOMETRY values is smaller or equal to the value of distanceExpr.

The units of the distance threshold are those of the coordinates of the input geometries.

The function returns NULL if any of the inputs is NULL.

Error conditions

Examples

SQL
-- Returns true as the distance between the point and linestring is within the threshold.
> SELECT st_dwithin(st_geomfromtext('POINT Z (0 0 300)'),st_geomfromtext('LINESTRING(-10 10,20 10)'), 10.0);
true
-- Returns false as the distance between the geometries exceeds the threshold.
> SELECT st_dwithin(st_geomfromtext('POINT(0 0)'),st_geomfromtext('POINT(20 20)'), 10.0);
false