Skip to content
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

QueryWithVars on facet filtering fails silently #2481

Closed
shanghai-Jerry opened this issue Jul 10, 2018 · 2 comments · Fixed by #4061
Closed

QueryWithVars on facet filtering fails silently #2481

shanghai-Jerry opened this issue Jul 10, 2018 · 2 comments · Fixed by #4061
Assignees
Labels
area/facets Issues related to face handling, querying, etc. area/querylang/vars Issues related to queries with GraphQL variables area/querylang Issues related to the query language specification and implementation. Check if resolved exp/intermediate Fixing this requires some experience with the project. kind/enhancement Something could be better. priority/P1 Serious issue that requires eventual attention (can wait a bit)
Milestone

Comments

@shanghai-Jerry
Copy link

shanghai-Jerry commented Jul 10, 2018

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

  • What version of Dgraph are you using?
    v1.0.6

  • Have you tried reproducing the issue with latest release?
    No

  • What is the hardware spec (RAM, OS)?
    Ubuntu, 128G

  • Steps to reproduce the issue (command/config used to run Dgraph).
    nohup dgraph zero -w zw5 --replicas 1 > info1 &
    nohup dgraph server -p p5 -w w5 --lru_mb 20000 --zero localhost:5080 > info2 &
    nohup dgraph-ratel > info3 &

  • Expected behaviour and actual result.

    i found a problem with query like this:

query withvar($a:string, $b:bool) {

query(func:uid($a)) {

candidate_school @facets(eq(on_edu,$b)) @groupby(name) {

  count(uid)
}
}
}

it doesn't have any result return, but when i use query like this:


{
query(func:uid(0x998a17)) {

candidate_school @facets(eq(on_edu,false)) @groupby(name) {

  count(uid)

}
}
}

it has result.

it seems that queryWithVars has a problem when query vars in facets.
@pawanrawal @sboorlagadda

refer : https://discuss.dgraph.io/t/query-and-querywithvars/2796/9

@srfrog srfrog added the kind/enhancement Something could be better. label Oct 12, 2018
@manishrjain manishrjain added the exp/intermediate Fixing this requires some experience with the project. label Jan 16, 2019
@campoy campoy added area/facets Issues related to face handling, querying, etc. area/querylang Issues related to the query language specification and implementation. area/querylang/vars Issues related to queries with GraphQL variables labels Jul 12, 2019
@campoy campoy added this to the Unplanned (v1.x) milestone Jul 12, 2019
@campoy
Copy link
Contributor

campoy commented Jul 12, 2019

This request makes total sense and should be considered at the same time as the others in the label https://github.com/dgraph-io/dgraph/labels/area%2Fquerylang%2Fvars

@campoy
Copy link
Contributor

campoy commented Sep 13, 2019

I reproduced this error.

Given this dataset:

{
  set {
    _:f <name> "Francesc" .
    _:f <works_in> _:sf (since="2018") .
    _:m <name> "Manish" .
    _:m <works_in> _:sf (since="2019") .
    _:i <name> "Ibrahim" .
    _:i <works_in> _:bg (since="2019") .
    _:sf <name> "San Francisco" .
    _:bg <name> "Bangalore" .
  }
}

I can query when someone started working and where with the following query:

query works($since: string = "2018") {
  q(func: has(works_in)) @cascade {
    name
    works_in @facets {
      name
    }
  }
}

This returns the following:

{
  "data": {
    "q": [
      {
        "name": "Manish",
        "works_in": [
          {
            "name": "San Francisco",
            "works_in|since": "2019"
          }
        ]
      },
      {
        "name": "Ibrahim",
        "works_in": [
          {
            "name": "Bangalore",
            "works_in|since": "2019"
          }
        ]
      },
      {
        "name": "Francesc",
        "works_in": [
          {
            "name": "San Francisco",
            "works_in|since": "2018"
          }
        ]
      }
    ]
  }
}

Now, we can filter by those that started working after 2018:

query works($since: string = "2018") {
  q(func: has(works_in)) @cascade {
    name
    works_in @facets @facets(gt(since, $since)) {
      name
    }
  }
}

This result is wrong, as you can see by the fact that 2018 results like "Francesc" still appear

{
  "data": {
    "q": [
      {
        "name": "Manish",
        "works_in": [
          {
            "name": "San Francisco",
            "works_in|since": "2019"
          }
        ]
      },
      {
        "name": "Ibrahim",
        "works_in": [
          {
            "name": "Bangalore",
            "works_in|since": "2019"
          }
        ]
      },
      {
        "name": "Francesc",
        "works_in": [
          {
            "name": "San Francisco",
            "works_in|since": "2018"
          }
        ]
      }
    ]
  }
}

But if you replace the variable $since with the value "2018" the behavior is correct!

query works($since: string = "2018") {
  q(func: has(works_in)) @cascade {
    name
    works_in @facets @facets(gt(since, "2018")) {
      name
    }
  }
}
{
  "data": {
    "q": [
      {
        "name": "Manish",
        "works_in": [
          {
            "name": "San Francisco",
            "works_in|since": "2019"
          }
        ]
      },
      {
        "name": "Ibrahim",
        "works_in": [
          {
            "name": "Bangalore",
            "works_in|since": "2019"
          }
        ]
      }
    ]
  }
}

@campoy campoy added the priority/P1 Serious issue that requires eventual attention (can wait a bit) label Sep 13, 2019
@campoy campoy changed the title Support QueryWithVars on facets QueryWithVars on facet filtering fails silently Sep 13, 2019
@harshil-goel harshil-goel self-assigned this Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/facets Issues related to face handling, querying, etc. area/querylang/vars Issues related to queries with GraphQL variables area/querylang Issues related to the query language specification and implementation. Check if resolved exp/intermediate Fixing this requires some experience with the project. kind/enhancement Something could be better. priority/P1 Serious issue that requires eventual attention (can wait a bit)
Development

Successfully merging a pull request may close this issue.

6 participants