-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I was recently playing around with the BNODE function and I think the SPARQL spec is not very clear on the behaviour of the BNODE function (1.2)wrapped in subqueries.
It states that every solution mapping will generate distinct blanknodes, similar to the behaviour of blanknodes within the construct template.
Constructs a blank node that is distinct from all blank nodes in the dataset being queried and distinct from all blank nodes created by calls to this constructor for other query solutions.
The following query, however, is interesting:
SELECT * WHERE {
{SELECT ?x1 ?x2 WHERE { ?x1 ?p ?o BIND(BNODE("a") AS ?x2) } LIMIT 2}
{SELECT ?x1 ?x3 WHERE { ?x1 ?p ?o BIND(BNODE("a") AS ?x3) } LIMIT 2}
}
The interpretation of the spec is quite special looking at some common query engines qlever Comunica
Both generate distinct blank nodes but only in the context of a single subquery, the generated blank nodes are however 'accidentally' the same for both subqueries and therefore you get the result:
?x2 | ?x3 |
---|---|
_:a1 | _:a1 |
_:a1 | _:a2 |
_:a2 | _:a1 |
_:a2 | _:a2 |
Blazegraph, on the other hand, generates the same blank node constantly (which is definitely wrong?)
I think the spec would benefit on adding something allowing the lines of:
Constructs a blank node that is distinct from all blank nodes in the dataset being queried and distinct from all blank nodes created by calls to this constructor for other query solutions, even accross subqueries.
Since I assume this is the correct interpretation, as the spec really tries to make you generate distinct blanknodes?
For the other interpretation, I had a conversation with @rubensworks, but he will be able to explain it best.