Peter Xu Peter Xu - 2 months ago 20
SQL Question

Teradata distance between two geo-coordinates using ST_SPHERICALDISTANCE

I have read that in Teradata Version 13 and onward you can use ST_SPHERICALDISTANCE for calculating geo-distance.
I written a simple test query in Teradata:

Select
Cast('POINT(-35.0000, 150.0000)' As ST_GEOMETRY) As location1,
Cast('POINT(-35.0000, 149.0000)' As ST_GEOMETRY) As location2,
location1.ST_SPHERICALDISTANCE(location2) As Distance_In_km


But received following error:


Teradata row not delivered (trget): 13
OGRGeometryFactoryX::createFromWkt failed.


Is this an issue with the query or configuration?
Thanks

Answer

Simply remove the comma within the point definition :)

Select
Cast('POINT(-35.0000 150.0000)' As ST_GEOMETRY) As location1,
Cast('POINT(-35.0000 149.0000)' As ST_GEOMETRY) As location2,
location1.ST_SPHERICALDISTANCE(location2) As Distance_In_km

Btw, another way to create a point:

NEW ST_GEOMETRY('POINT(-35.0000 150.0000)')