dgraph-io / dgraph

The high-performance database for modern applications
https://dgraph.io
Other
20.31k stars 1.49k forks source link

Shortest path does not respect depth limitation #3658

Closed campoy closed 5 years ago

campoy commented 5 years ago

If you suspect this could be a bug, follow the template.

play.dgraph.io

yes

N/A

Run this query on play.dgraph.io:

{
{
  path as shortest(from: 0x22f1e0, to: 0x82ec65, depth:2) {
    <director.film>
    <actor.film>
    <starring>
    <performance.actor>
  }
  path(func: uid(path)) {
    uid
    name@.
  }
}

It should not return anything, as the shortest path is of length 4 and we limited depth:2.

Instead we get the following:

{
  "extensions": {
    "server_latency": {
      "parsing_ns": 22070,
      "processing_ns": 47019709,
      "encoding_ns": 874521
    },
    "txn": {
      "start_ts": 22790001
    }
  },
  "data": {
    "path": [
      {
        "uid": "0x22f1e0",
        "name@.": "Steven Spielberg"
      },
      {
        "uid": "0x414ee0",
        "name@.": "Jurassic Park"
      },
      {
        "uid": "0x14f22a"
      },
      {
        "uid": "0x82ec65",
        "name@.": "Jeff Goldblum"
      }
    ],
    "_path_": [
      {
        "director.film": [
          {
            "starring": [
              {
                "performance.actor": [
                  {
                    "uid": "0x82ec65"
                  }
                ],
                "uid": "0x14f22a"
              }
            ],
            "uid": "0x414ee0"
          }
        ],
        "uid": "0x22f1e0"
      }
    ]
  }
}
campoy commented 5 years ago

Never mind ... turns out the depth is the number of hops, no the length of the path.

Probably worth updating the specs!