st_geometrytype
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 the type of the input GEOGRAPHY
or GEOMETRY
value as a string.
Syntax
st_geometrytype ( geoExpr )
Arguments
geoExpr
: AGEOGRAPHY
orGEOMETRY
value.
Returns
A value of type STRING
, representing the type of the input geometry.
The value returned is as follows:
- For points, the expression returns
ST_Point
. - For linestrings, the expression returns
ST_LineString
. - For polygons, the expression returns
ST_Polygon
. - For multipoints, the expression returns
ST_MultiPoint
. - For multilinestrings, the expression returns
ST_MultiLineString
. - For multipolygons, the expression returns
ST_MultiPolygon
. - For geometry collections, the expression returns
ST_GeometryCollection
.
The function returns NULL
if the input is NULL
.
Examples
SQL
-- Returns the type of a point geometry.
> SELECT st_geometrytype(st_geomfromtext('POINT(4 5)'));
ST_Point
-- Returns the type of a geometry collection.
> SELECT st_geometrytype(st_geomfromtext('GEOMETRYCOLLECTION(POINT(4 5),LINESTRING(-4 5,7 8))'));
ST_GeometryCollection