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

Multiple OPTIONALs mishandled #278

Closed
niklas88 opened this issue Aug 28, 2019 · 1 comment
Closed

Multiple OPTIONALs mishandled #278

niklas88 opened this issue Aug 28, 2019 · 1 comment
Assignees
Labels
very important very important issue with priority

Comments

@niklas88
Copy link
Member

Take the following query, each OPTIONAL on its own works giving an empty column. With both OPTIONAL the result is empty. It looks like the second OPTIONAL is done as a normal Join.

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
SELECT ?qleverui_entity ?qleverui_name ?qleverui_altname ?qleverui_count WHERE {
    {
      SELECT ?qleverui_entity (COUNT(?about) AS ?qleverui_count) WHERE {
        ?about schema:about ?x .
        ?about ql:has-predicate ?qleverui_entity .
      }
      GROUP BY ?qleverui_entity
    }
    OPTIONAL {
      ?qleverui_claim <http://wikiba.se/ontology#directClaim> ?qleverui_entity .
      ?qleverui_claim @en@<http://www.w3.org/2000/01/rdf-schema#label> ?qleverui_name .
    }
    OPTIONAL {
      ?qleverui_claim_2 <http://wikiba.se/ontology#directClaim> ?qleverui_entity .
      ?qleverui_claim_2 @en@<http://www.w3.org/2004/02/skos/core#altLabel> ?qleverui_altname .
    }

}
ORDER BY DESC(?qleverui_count)
LIMIT 40
@niklas88 niklas88 added bug very important very important issue with priority and removed bug labels Sep 6, 2019
@niklas88
Copy link
Member Author

niklas88 commented Sep 6, 2019

Here is a reproducer on the scientists KB, this should give us a list of all Scientists, not only 134.

SELECT ?x ?height ?partner WHERE  {
        ?x <is-a> <Scientist> .
        OPTIONAL { ?x <Height> ?height . }
        OPTIONAL { ?x <Spouse_(or_domestic_partner> ?partner}
}

And this is the operations tree, I think the outer most Join should also be an OptionalJoin

│
├─ Join on ?x
│  result_size: 134 x 3
│  columns: ?x, ?height, ?partner
│  total_time: 0.00 ms
│  operation_time: 0.00 ms
│  cached: true
│    original_operation_time: 0.00
│    original_total_time: 0.00
│  ┬
│  │
│  ├─ OptionalJoin on ?x
│  │  result_size: 134 x 3
│  │  columns: ?x, ?height, ?partner
│  │  total_time: 0.00 ms
│  │  operation_time: 0.00 ms
│  │  cached: false
│  │  ┬
│  │  │
│  │  ├─ IndexScan ?x <Height> ?height
│  │  │  result_size: 134 x 2
│  │  │  columns: ?x, ?height
│  │  │  total_time: 0.00 ms
│  │  │  operation_time: 0.00 ms
│  │  │  cached: true
│  │  │    original_operation_time: 26.00
│  │  │    original_total_time: 26.00
│  │  │
│  │  ├─ IndexScan ?x <Spouse_(or_domestic_partner> ?partner
│  │  │  result_size: 0 x 2
│  │  │  columns: ?x, ?partner
│  │  │  total_time: 0.00 ms
│  │  │  operation_time: 0.00 ms
│  │  │  cached: false
│  │
│  ├─ IndexScan ?x <is-a> <Scientist>
│  │  result_size: 19,361 x 1
│  │  columns: ?x
│  │  total_time: 0.00 ms
│  │  operation_time: 0.00 ms
│  │  cached: true
│  │    original_operation_time: 38.00
│  │    original_total_time: 38.00

niklas88 added a commit that referenced this issue Sep 15, 2019
Made the join of two optional results optional. Fixes #278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
very important very important issue with priority
Projects
None yet
Development

No branches or pull requests

2 participants