-
Notifications
You must be signed in to change notification settings - Fork 554
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
BIND not working as expected in SPARQL #580
Comments
In @joernhees branch, the simple test without a union (
This is not meant to work. The group has it's own scope, and ?x is not visible inside. This also holds for UNION (which also induces it's own scope). This is exactly what bind07 tests: https://www.w3.org/2009/sparql/docs/tests/summary.html#bind-bind07 and also bind10: https://www.w3.org/2009/sparql/docs/tests/summary.html#bind-bind10 The tests don't have a simple BIND in a group example, but you can see here that groups and unions should be treated the same: https://www.w3.org/TR/sparql11-query/#variableScope I would claim to Cortese and Virtuoso are wrong :) |
I agree that the
Now, the result should be (?s=x:jane, ?o=x:john, ?x=x:jane). Indeed, the group would return two bindings: (?s=?x=x:jane) and (?s=?x=x:john), The same thing happens in the original query I proposed. So I claim that Corese and Virtuoso are not wrong :) But granted, this is a tricky problem! :-/ |
@pchampin thanks for the quick clarification! Even though it's one year since you first reported the issue! I wasn't really very confident in declaring Virtuoso/Corese wrong, so I didn't close the issue :) I see my error now, the bind doesn't see vars from outside, but that's not what you try to do. You use the bind to "rename" a variable inside, which then has another name outside. I'll dig into it again! |
So I fixed it. It was again caused by complications from doing lazy join evaluations (where the SPARQL engine "illegally" passes bindings from one side of a join into the other), just like: #615 These illegally passed bindings sometimes have to be forgotten, to fix scoping rules. Here we forgot too much. Your solution was very close @joernhees! Although the examples given here now all work, I am not totally confident I have gotten them all. I think there are probably more edge-cases with sub-queries and/or exists clauses where the internal variables sort of have their own space. (I have more or less ignored the "substitute" function defined here: https://www.w3.org/TR/sparql11-query/#sparqlAlgebraEval) Doing #619 will probably highlight more. |
awesome, thanks for fixing that... i guess #601 can be closed? (as far as i can see you rebased the stuff from it that made sense?) |
Ok, consider the following data:
and the following query:
The goal of the query is to extract all incoming and outgoing arcs of every
s:Person
in the data(and ultimately to construct a graph with those, but I use
SELECT
for debugging).As I understand, the result should be
At least, this is what I get with Corese and Virtuoso.
But instead I get
so the
BIND
(in this configuration) does not seem to work.NB: the
UNION
is not the cause of the problem. I have the same problem without anyUNION
.The text was updated successfully, but these errors were encountered: