Skip to content

Interpretation of BNODE under subquery #292

@jitsedesmet

Description

@jitsedesmet

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions