W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2010

Blank node and nested queries

From: Andy Seaborne <andy.seaborne@talis.com>
Date: Mon, 19 Apr 2010 09:19:00 +0100
Message-ID: <4BCC11F4.8040608@talis.com>
To: SPARQL Working Group <public-rdf-dawg@w3.org>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:42 GMT