-
Notifications
You must be signed in to change notification settings - Fork 560
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
Subselect clause under optional clause fails in RDFlib #2957
Comments
Is there anything I can do to get this issue fixed? I hope my example is clear but if not, let me know and I ll try to explain it better. |
For your example query a workaround would be, to rearrange the search order: prefix ex: <https://www.example.org/>
select ?subject ?car
where {
# optional clause
optional
{
# an offending subselect clause
select ?car
where {
?car ex:type "Car".
}
}
$this ex:subject ?subject.
} I searched a little bit for an error and found out, that the processor kicks out the solution for rdflib/rdflib/plugins/sparql/evaluate.py Lines 560 to 563 in 28a6190
I wont get any further today. I hope this helps a little bit. I dont know, when i'm continuing this. |
Thanks WhiteGobo! In my opinion this is a high impact issue that lowers the reliability of the SPARQL engine considerably. I often write queries with subselect queries, hence this issue worries me. Thank you for your analysis! |
A subselect clause under an optional clause fails in RDFlib. Let us consider the following example:
I want to be able to query this graph and put all cars in some document about cars, if there are any cars. I use a subselect clause under an optional clause. The real reason for the subselect is that I want to count the number of cars (optionally being zero), but that is not relevant here. The example code is simple, does not involve an aggregate, but fails to yield the correct results.
I would expect the following results:
Instead I get:
So the variable subject is incorrectly not bound in the result set.
If I would query with the optional clause and an ordinary triple pattern without a subselect clause, then I get the results I want:
Expected and achieved results:
I have tested the offending subselect query under the following engines:
RDFlib, JENA, Speedy and Virtuoso. Only RDFlib results in the 'none' binding for subject, the three other engines show the expected results.
The text was updated successfully, but these errors were encountered: