TO_GEOMETRY (Lakehouse v1)
Analisa uma entrada e retorna um valor do tipo GEOMETRY.
TRY_TO_GEOMETRY retorna um valor NULL se ocorrer um erro durante a análise.
Sintaxe SQL
Seção intitulada “Sintaxe SQL”TO_GEOMETRY(<string>, [<srid>])TO_GEOMETRY(<binary>, [<srid>])TO_GEOMETRY(<variant>, [<srid>])TRY_TO_GEOMETRY(<string>, [<srid>])TRY_TO_GEOMETRY(<binary>, [<srid>])TRY_TO_GEOMETRY(<variant>, [<srid>])Argumentos
Seção intitulada “Argumentos”| Argumentos | Descrição |
|---|---|
<string> |
O argumento deve ser uma expressão de string em WKT, EWKT, WKB ou EWKB no formato hexadecimal, ou no formato GeoJSON. |
<binary> |
O argumento deve ser uma expressão binária no formato WKB ou EWKB. |
<variant> |
O argumento deve ser um OBJECT JSON no formato GeoJSON. |
<srid> |
O valor inteiro do SRID a ser usado. |
Tipo de retorno
Seção intitulada “Tipo de retorno”Geometry.
Exemplos de SQL
Seção intitulada “Exemplos de SQL”SELECT TO_GEOMETRY( 'POINT(1820.12 890.56)' ) AS pipeline_geometry;
┌───────────────────────┐│ pipeline_geometry │├───────────────────────┤│ POINT(1820.12 890.56) │└───────────────────────┘
SELECT TO_GEOMETRY( '0101000020797f000066666666a9cb17411f85ebc19e325641', 4326 ) AS pipeline_geometry;
┌───────────────────────────────────────┐│ pipeline_geometry │├───────────────────────────────────────┤│ SRID=4326;POINT(389866.35 5819003.03) │└───────────────────────────────────────┘
SELECT TO_GEOMETRY( FROM_HEX('0101000020797f000066666666a9cb17411f85ebc19e325641'), 4326 ) AS pipeline_geometry;
┌───────────────────────────────────────┐│ pipeline_geometry │├───────────────────────────────────────┤│ SRID=4326;POINT(389866.35 5819003.03) │└───────────────────────────────────────┘
SELECT TO_GEOMETRY( '{"coordinates":[[389866,5819003],[390000,5830000]],"type":"LineString"}' ) AS pipeline_geometry;
┌───────────────────────────────────────────┐│ pipeline_geometry │├───────────────────────────────────────────┤│ LINESTRING(389866 5819003,390000 5830000) │└───────────────────────────────────────────┘
SELECT TO_GEOMETRY( PARSE_JSON('{"coordinates":[[389866,5819003],[390000,5830000]],"type":"LineString"}') ) AS pipeline_geometry;
┌───────────────────────────────────────────┐│ pipeline_geometry │├───────────────────────────────────────────┤│ LINESTRING(389866 5819003,390000 5830000) │└───────────────────────────────────────────┘