-
Notifications
You must be signed in to change notification settings - Fork 872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating an SQL function that uses a SPATIAL INDEX and NEAR with maxDistance fails (NullPointerException and no results) #6776
Comments
A workaround function is defined as follows:
Not sure if that helps or not, but it seems much slower than the equivalent NEAR clause. The workaround above does not work without the |
One more thing, a select query against the same data, like the following, works fine:
|
@danstruthers btw i would recommend to use the new Spatial module for 2.2.x orientdb.com/docs/2.2/Spatial-Index.html |
@danstruthers
|
Using colons instead of $s just gets rid of the exception server side. I still get no results. The $s work in the workaround function, which does return results. I am using the new spatial module for 2.2.11. I thought the NEAR SQL keyword was part of the spatial module. I could try the ST_xxx functions to see if they will work. |
this works for me
|
Sorry, I was testing it inside Studio in the Functions tab (where I just get an empty array as the result set). Inside the Browse tab it work as expected now. I tried the ":" binding before (after reading some other posts), but only tried to test it using the functions tab in studio (using the execute button at the bottom of the panel). I will not rely on that in the future. Why does my workaround function work with $ bound variables, but this one does not? Thank you for your help! |
let me check about Studio Function tab. I did not test it. I guess because they are used in function distance. |
i'v found that Studio uses the old functions http api that send the parameters as string. That is why is's not working with studio. |
@maggiolo00 What's the status of this issue? |
@lvca i've opened I'm closing this since it's an enhancements fo Studio Function Management |
v2.2.11
Operating System
Expected behavior and actual behavior
It is expected that I can create a function that returns a set of vertices that are near a particular latitude/longitude pair (with max_dist kilometers), using
WHERE [x,y,$spatial] NEAR [$a,$b,{maxDistance, $c}]
(where $a, $b, and $c are function parameters).What I get is no results, and this error in the server log:
Steps to reproduce the problem
CREATE CLASS GeoLocation EXTENDS V
CREATE PROPERTY GeoLocation.latitude Double
CREATE PROPERTY GeoLocation.longitude Double
CREATE INDEX GeoLocation.lat_lon ON GeoLocation (latitude, longitude) SPATIAL ENGINE LUCENE
...insert a bunch of GeoLocation data from somewhere (attached, using oetl)
citystate.zip...
CREATE FUNCTION findNearby "SELECT FROM GeoLocation WHERE [latitude, longitude, $spatial] NEAR [$lat, $lon, {maxDistance: $max_dist}]" PARAMETERS [lat,lon,max_dist] LANGUAGE SQL
SELECT EXPAND(findNearby(45.0, -122.0, 300))
The text was updated successfully, but these errors were encountered: