Problem with distance query

Hey there,
I have a problem with some geospacial queries in crateDB, especially distance

I have a query like

SELECT date, creation_date, code, distance([latitude, longitude], [48.58916271607118, 2.0338593032353143 ])::integer as distance
FROM "doc"."weather_2_hourly" 
where date = '2024-12-24T00:00' 
and distance([latitude, longitude], [48.58916271607118, 2.0338593032353143 ]) < 100000
order by distance desc 
LIMIT 10;

and I get an error like

UnsupportedFeatureException[Cannot ORDER BY ''Pt(x=48.58916271607118,y=2.0338593032353143)'': invalid data type 'geo_point'.]

The funny part is that if I order by date for example, I very well see the distance as a number, and the numerical operator works also, just the order does not do it.

Any help/hint would be appreciated

1 Like

Hi @joheams,

This looks like a bug to me. Ordering by GEO_POINT is not supported, as documented in ORDER BY. But here you order by the output of DISTANCE which returns DOUBLE and should work.

Would you mind reporting it as an issue on GitHub? Our developers can then validate if it is indeed a bug in the data type validation. Thanks!

1 Like

Thanks, just updated to the latest version and it works now as it seems

1 Like