適用於:
Databricks SQL
Databricks Runtime 17.1 和更新版本
Important
這項功能目前處於 公開預覽版。
備註
這項功能不適用於 Databricks SQL Classic 倉儲。 若要深入瞭解 Databricks SQL 倉儲,請參閱 SQL 倉儲類型。
剖析地理描述的輸入並傳回對應的 GEOGRAPHY 值,或在輸入描述無效時傳回 NULL。
傳回 GEOGRAPHY 值的 SRID 值為 4326。
Syntax
try_to_geography ( geoRepExpr )
Arguments
Returns
GEOGRAPHY(ANY)型的值,與輸入的地理位置描述相對應。
- 如果輸入為
NULL,則函式會傳NULL回 。 - 如果輸入
NULL或BINARY值是地理位置的無效描述,則函式會傳回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