try_to_geography 函数

适用于:检查标记为“是”的 Databricks SQL 检查标记为“是”是 Databricks Runtime 17.1 及更高版本

Important

此功能目前以公共预览版提供。

注释

此功能在 Databricks SQL 经典仓库上不可用。 若要详细了解 Databricks SQL 仓库,请参阅 SQL 仓库类型

分析地理位置的输入说明并返回相应的 GEOGRAPHY 值;如果输入说明无效,则返回 NULL。 返回 GEOGRAPHY 值的 SRID 值为 4326。

Syntax

try_to_geography ( geoRepExpr )

Arguments

  • geoRepExpr:表示 BINARYSTRINGWKBWKTGeoJSON 中的地理的表达式。

Returns

一个类型 GEOGRAPHY(ANY)值,对应于输入地理说明。

  • 如果输入为 NULL.,则函数返回 NULL
  • 如果输入NULLBINARY值对地理的描述无效,该函数将STRING返回。

Examples

-- Input geography is in WKT format.
> SELECT st_asgeojson(try_to_geography('POINT Z (3 4 5)'));
  {"type":"Point","coordinates":[3,4,5]}

-- Input geography is in GeoJSON format.
> SELECT st_asewkt(try_to_geography('{"type":"Point","coordinates":[3,4,5]}'));
  SRID=4326;POINT Z (3 4 5)

-- Input geography is in WKB format.
> SELECT st_astext(try_to_geography(X'01b90b0000000000000000084000000000000010400000000000001440000000000000f0bf'))
  POINT ZM (3 4 5 -1)

-- Input value is not the description of a geography.
> SELECT st_astext(try_to_geography('some string that does not represent a geography'))
  NULL