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

OPTIONAL leads to no results #108

Closed
niklas88 opened this issue Aug 21, 2018 · 2 comments
Closed

OPTIONAL leads to no results #108

niklas88 opened this issue Aug 21, 2018 · 2 comments
Assignees
Labels

Comments

@niklas88
Copy link
Member

niklas88 commented Aug 21, 2018

The following query generated by Aqqu for the "start of Hoover's (fb:m.03kdl) presidency" yields no results.

PREFIX fb: <http://rdf.freebase.com/ns/>

SELECT  ?1 ?1name WHERE {
 fb:m.060d2 fb:government.government_office_or_title.office_holders ?0 .
 ?0 fb:government.government_position_held.office_holder fb:m.03kdl .
 ?0 fb:government.government_position_held.from ?1 .
 OPTIONAL {?1 fb:type.object.name ?1name} .
 FILTER (?1 != fb:m.060d2 && ?1 != fb:m.03kdl) 
} LIMIT 300

Removing the OPTIONAL line however reveals there should be a result.

It doesn't seem to be related to ?1 not having that relation at all however as removing

fb:m.060d2 fb:government.government_office_or_title.office_holders ?0 .

which restricts to the "President of the United States" also yields the result.

This is the QLever log: qlever_log_optional_sort.txt
my guess would be that the SORT operation is not propagating the _isOptional flag correctly. I'll investigate later.

@niklas88 niklas88 changed the title OPTIOANL leads to no results, may be related to intermediate SORT OPTIONAL leads to no results, may be related to intermediate SORT Aug 21, 2018
@niklas88
Copy link
Member Author

So here is what I could gather so far. It doesn't seem to be the SORT as the following working query

PREFIX fb: <http://rdf.freebase.com/ns/>

SELECT ?1  ?1name WHERE {
 ?0 fb:government.government_position_held.office_holder fb:m.03kdl .
 ?0 fb:government.government_position_held.from ?1 .
 OPTIONAL {?1 fb:type.object.name ?1name} .
}
LIMIT 300
ORDER BY ?0

gives the exact execution plan of the right side of the following queries' outer most JOIN (the same as the first query just withput FILTER)

PREFIX fb: <http://rdf.freebase.com/ns/>

SELECT ?1  ?1name WHERE {
 fb:m.060d2 fb:government.government_office_or_title.office_holders ?0 .
 ?0 fb:government.government_position_held.office_holder fb:m.03kdl .
 ?0 fb:government.government_position_held.from ?1 .
 OPTIONAL {?1 fb:type.object.name ?1name} .
}
LIMIT 300

qlever_log_optional_sort_2.txt

So to me it looks like JOIN on results of OPTIONAL_JOIN is broken. We really need some e2e Test queries with OPTIONAL (i.e. #68)

@niklas88 niklas88 changed the title OPTIONAL leads to no results, may be related to intermediate SORT OPTIONAL leads to no results Aug 21, 2018
@niklas88 niklas88 added the bug label Aug 21, 2018
@niklas88
Copy link
Member Author

niklas88 commented Aug 21, 2018

Ok so the problem is that the result of the OPTIONAL_JOIN estimates it's size as 0 because somehow we know that the OPTIONAL part is indeed empty. Then this function literally takes the size estimate at face value

bool QueryExecutionTree::knownEmptyResult() { return getSizeEstimate() == 0; }

and the JOIN takes it as known empty.

So @floriankramer @Buchhold we should either document that the size estimate may only be 0 iff it is exactly known. Or we need to change the test for knownEmptyResult().

niklas88 added a commit that referenced this issue Aug 24, 2018
Don't estimate OPTIONAL_JOIN size as 0 fixes #108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants