Search code examples
memgraphdb

Problems with temporal types like duration in of the wShortest aggregate function


I have v2.0 of Memgraph, seems like temporal types like duration can't be part of the wShortest aggregate function. Here is my code:

MATCH (n) DETACH DELETE n;
CREATE
    (storage {name: "storage", current_time: localtime("T11:00")}),
    (tape {name: "tape"}),
    (lto {name: "lto"}),
    (archive1 {name: "archive1", opens: localtime("T10:00"), closes: localtime("T11:00")}),
    (archive2 {name: "archive2", opens: localtime("T08:00"), closes: localtime("T10:00")}),
    (archive3 {name: "archive3", opens: localtime("T13:00"), closes: localtime("T16:00")}),
    (archive4 {name: "archive4", opens: localtime("T15:00"), closes: localtime("T19:00")}),
    (storage)-[:Fetch {duration: duration("3H")}]->(tape),
    (storage)-[:Fetch {duration: duration("1H")}]->(lto),
    (tape)-[:Drive {duration: duration("2H")}]->(archive1),
    (tape)-[:Drive {duration: duration("4H")}]->(archive2),
    (lto)-[:Ride {duration: duration("5H")}]->(archive3),
    (lto)-[:Ride {duration: duration("4H")}]->(archive)
;

Here is wShortest query:

MATCH (a {name: "storage"})-[edge_list *wShortest 10 (e, n | e.duration) fetch_time]->(b)
RETURN *;

The error that I get is Error: Query failed: Calculated weight must be numeric, got duration.


Solution

  • This was a bug that was fixed with Memgraph 2.1.0 release. In the changelog it says: Allow duration values to be used as weights in the Weighted Shortest Path query.