arcadedb icon indicating copy to clipboard operation
arcadedb copied to clipboard

SQL: "dijkstra" function does not accept documented arguments

Open gramian opened this issue 10 months ago • 1 comments

ArcadeDB Version 25.2.1-SNAPSHOT

The dijkstra function does not work as described, for example (SQLscript):

CREATE VERTEX TYPE V;
CREATE EDGE TYPE E;
CREATE PROPERTY E.distance LONG;

LET $src = (INSERT INTO V);
LET $dst = (INSERT INTO V);
CREATE EDGE E FROM $src TO $dst SET distance = 1;
CREATE EDGE E FROM $src TO $dst SET distance = 10;

LET $src = (SELECT FROM V LIMIT 1);
LET $dst = (SELECT FROM V LIMIT 1 SKIP 1);
SELECT dijkstra($src, $dst, 'distance') FROM V;

results in the error:

Error on command execution (PostCommandHandler): class com.arcadedb.graph.ImmutableVertex cannot be cast to class java.lang.String (com.arcadedb.graph.ImmutableVertex is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')

Similarly, using instead:

LET $src = (SELECT FROM V LIMIT 1);
LET $dst = (SELECT FROM V LIMIT 1 SKIP 1);
SELECT dijkstra($src.@rid, $dst.@rid, 'distance') FROM V;

results in the error:

Error on command execution (PostCommandHandler): class com.arcadedb.database.RID cannot be cast to class java.lang.String (com.arcadedb.database.RID is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')

So it seems the source and destination arguments for the dijkstra function are not parsed correctly.

This issue was reported by the user kyurina on Discord

gramian avatar Jan 31 '25 19:01 gramian

It seems the astar SQL function has the same / a similar problem. Note, dijkstra calls astar, see https://github.com/ArcadeData/arcadedb/blob/main/engine/src/main/java/com/arcadedb/query/sql/function/graph/SQLFunctionDijkstra.java#L48

gramian avatar Feb 10 '25 10:02 gramian