Blank node and nested queries

In SPARQL 1.0 the following query is illegal because the label "a" is 
used twice in different BGPs.

PREFIX : <http://example/>

SELECT *
{
  _:a :p ?x .
  OPTIONAL { _:a :w ?y }
}

We have a choice in SPARQL 1.1 Query as to whether this scoping rule 
applies to the query or the SELECT statement.

In SPARQL 1.1, we now have nested SELECTs.  It is convenient to be able 
to paste one SELECT, having got it working, into another query.  Having 
to check labels stops a simple cut&paste of we decide the scope is the 
query.

PREFIX : <http://example/>

SELECT *
{
   _:a :p ?x .
   { SELECT * { _:a :p ?y } }
}

I suggest that we clarify blank node scoping rule to apply to one SELECT 
statement, not the whole query, making the SPARQL 1.1 query above legal.

Analogous things happen with unprojected variables:

PREFIX : <http://example/>

SELECT *
{
   :a :p ?x .
   { SELECT (COUNT(*) AS ?C) { :a :q ?x } }
}

The two ?x are unrelated - they never meet at an operation that causes a 
join over them.

CONSTRUCTs already allow labels to be used twice.

CONSTRUCT { _:a :p ?x } WHERE { _:a :q ?x }

 Andy

Received on Monday, 19 April 2010 08:19:33 UTC