Skip to main content

ST_GEOMETRYTYPE

Description

Returns the type name (in uppercase) of a given geometry object. Used to identify the specific type of a geometric shape.

Note

Supported since Apache Doris 4.0.4

Syntax

ST_GEOMETRYTYPE( <shape> )

Parameters

ParameterDescription
<shape>The input geometry, of type GEOMETRY or VARCHAR (in WKT format) that can be converted to GEOMETRY.

Return Value

Returns a VARCHAR type uppercase string representing the geometry object's type.

ST_GEOMETRYTYPE has the following edge cases:

  • If the input parameter is NULL, returns NULL.
  • If the input parameter cannot be parsed into a valid geometry object, returns NULL.
  • Supported geometry types and their return value examples are as follows:
    • POINT: "ST_POINT"
    • LINESTRING: "ST_LINESTRING"
    • POLYGON: "ST_POLYGON"
    • MULTIPOLYGON: "ST_MULTIPOLYGON"
    • CIRCLE : "ST_CIRCLE"

Example

Type of a Point

SELECT ST_GEOMETRYTYPE(ST_GeometryFromText('POINT(1 1)'));
+----------------------------------------------------+
| ST_GEOMETRYTYPE(ST_GeometryFromText('POINT(1 1)')) |
+----------------------------------------------------+
| ST_POINT |
+----------------------------------------------------+

Type of a Line

SELECT ST_GEOMETRYTYPE(ST_LineFromText("LINESTRING (1 1,2 2,3 3)"));
+--------------------------------------------------------------+
| ST_GEOMETRYTYPE(ST_LineFromText("LINESTRING (1 1,2 2,3 3)")) |
+--------------------------------------------------------------+
| ST_LINESTRING |
+--------------------------------------------------------------+

Type of a Polygon

SELECT ST_GEOMETRYTYPE(ST_GeometryFromText('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'));
+--------------------------------------------------------------------------------+
| ST_GEOMETRYTYPE(ST_GeometryFromText('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))')) |
+--------------------------------------------------------------------------------+
| ST_POLYGON |
+--------------------------------------------------------------------------------+

Type of a Circle (Doris Extension)

SELECT ST_GEOMETRYTYPE(ST_Circle(0, 0, 100));
+---------------------------------------+
| ST_GEOMETRYTYPE(ST_Circle(0, 0, 100)) |
+---------------------------------------+
| ST_CIRCLE |
+---------------------------------------+

Invalid Parameter (Returns NULL)

SELECT ST_GEOMETRYTYPE('NOT_A_GEOMETRY');
+-----------------------------------+
| ST_GEOMETRYTYPE('NOT_A_GEOMETRY') |
+-----------------------------------+
| NULL |
+-----------------------------------+

NULL Parameter

SELECT ST_GEOMETRYTYPE(NULL);
+-----------------------+
| ST_GEOMETRYTYPE(NULL) |
+-----------------------+
| NULL |
+-----------------------+