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

Treat GraphPatterns in Query Bodies more correctly. #324

Closed
wants to merge 14 commits into from

Conversation

joka921
Copy link
Member

@joka921 joka921 commented Apr 17, 2020

TODO: this is a continuation of PR #323 , so that one should be reviewed + merged before.

  • The previous version put all triples and filters that appeared directly in a WHERE clause together.

  • this is not correct, since always when an OPTIONAL, UNION, SUBQUERY etc. appears a new scope
    is started. For example in
    SELECT ?x ?y WHERE {
    ?x
    OPTIONAL { ?x ?y}
    FILTER ?x < <Ada_Lovelace>
    }
    the filter should have no effect, because it is not in the same scope as the x is a scientist triple.
    the probably more useful query would be
    SELECT ?x ?y WHERE {
    ?x .
    FILTER ?x < <Ada_Lovelace>
    OPTIONAL { ?x ?y}
    }
    where the filter is actually applied on the entities that are scientists.
    However, QLever previously handled these queries both in the second way.

  • To correct this, implemented a BasicGraphPattern (triples, filters and values that are "directly" in the Body of another graph pattern or a WHERE clause) class.
    BasicGraphPatterns are also children of their parent body.

  • In addition, Optionals were also treated wrong as the GraphPatterns must be treated in order which makes a difference for Optionals.

  • This version of the QueryPlanner does some degree of optimization, however one could optimize multiple adjacent GraphPatterns that are not Optional, if their
    scopes are respected.

  • TODO: There still are bugs in the handling of optionals as the SPARQL standard knows "unbound values" which can be rebound, e.g.

    SELECT ?x ?name WHERE {
    ?x
    OPTIONAL {?x ?name}
    OPTIONAL {?x rdfs:label ?name }
    }
    which should only add the names only for humans that don't have twitter accounts and the handling of the empty query
    SELECT ?x WHERE {} (1 result where ?x is unbound/NULL)

  • TODO: Some candidate plans found by optimizing a TransitivePath are currently unable to be joined with adjacent patterns.
    It seems that we can always find a suitable candidate, so that this works, but we still should inspect, whether this is the correct behavior.

…childGraphPattern types

- Todo : remove outcommented code
- Todo: reinstate the "toString" class.
Start simplifying the parsedQuery by removing the unnecessary shared_ptr and manual constructor shenanigans.
- The previous version put all triples and filters that appeared directly in a WHERE clause together.
- this is not correct, since always when an OPTIONAL, UNION, SUBQUERY etc. appears a new scope
  is started. For example in
  SELECT ?x ?y WHERE {
    ?x <is-a> <Scientist>
    OPTIONAL { ?x <Spouse> ?y}
    FILTER ?x < <Ada_Lovelace>
  }
  the filter should have no effect, because it is not in the same scope as the x is a scientist triple.
  the probably more useful query would be
  SELECT ?x ?y WHERE {
    ?x <is-a> <Scientist> .
    FILTER ?x < <Ada_Lovelace>
    OPTIONAL { ?x <Spouse> ?y}
  }
  where the filter is actually applied on the entities that are scientists.
  However, QLever previously handled these queries both in the second way.

- To correct this, implemented a BasicGraphPattern (triples, filters and values that are "directly" in the Body of another graph pattern or a WHERE clause) class.
  BasicGraphPatterns are also children of their parent body.

- In addition, Optionals were also treated wrong as the GraphPatterns must be treated in order which makes a difference for Optionals.

- This version of the QueryPlanner does some degree of optimization, however one could optimize multiple adjacent GraphPatterns that are not Optional, if their
  scopes are respected.

- TODO: There still are bugs in the handling of optionals as the SPARQL standard knows "unbound values" which can be rebound, e.g.

  SELECT ?x ?name WHERE {
    ?x <is-a> <human>
    OPTIONAL {?x <TwitterAccount> ?name}
    OPTIONAL {?x rdfs:label ?name }
  }
  which should only add the names only for humans that don't have twitter accounts and the handling of the empty query
  SELECT ?x WHERE {} (1 result where ?x is unbound/NULL)

- TODO: Some candidate plans found by optimizing a TransitivePath are currently unable to be joined with adjacent patterns.
        It seems that we can always find a suitable candidate, so that this works, but we still should inspect, whether this is the correct behavior.
@joka921 joka921 closed this Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant