W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > July to September 2009

Variable scope for subqueries

From: Lee Feigenbaum <lee@thefigtrees.net>
Date: Mon, 31 Aug 2009 01:45:54 -0400
Message-ID: <4A9B6392.3090302@thefigtrees.net>
To: SPARQL Working Group <public-rdf-dawg@w3.org>
This is in reference to ISSUE-4 
(http://www.w3.org/2009/sparql/track/issues/4) and is in discharge of 
ACTION-16.

At the F2F, we had a short discussion about variable scope and 
subqueries: http://www.w3.org/2009/sparql/meeting/2009-05-07#line0199

At the time, Axel asked for a fleshed out example of the query that Andy 
used on IRC to demonstrate the scoping issue.

Andy's query on IRC was :

SELECT * { {?x :p ?v } { SELECT * { ?x :q ?w FILTER (?v>3) } } }

...but I don't believe that demonstrates the proper issue. The above 
query has the (non-)issue of whether ?v is visible inside the subquery. 
I believe that SPARQL Query/1.0 already answers that: the bottom-up 
nature of SPARQL's algebra means that the scope of the FILTER is within 
the subquery's group. The only way that this FILTER would apply to 
bindings from the {?x :p ?v} BGP is via a top-down evaluation model, and 
that would be a breaking change to current SPARQL semantics.

Instead, I think this query demonstrates the scoping issue for subqueries:

SELECT * { ?x :p1 ?y {SELECT ?x { ?x :p 2?y }} FILTER(?y > 3)}

The question is, I think, does the subquery's projection completely hide 
the "inner" ?y from the rest of the query? I believe there was clear 
consensus at the F2F that the answer is "yes", which is consistent with 
current SPARQL bottom-up semantics and with projection in general.

Anyway, having reviewed this issue, I think it's more of a non-issue, as 
I haven't seen any advocates for an alternative approach. If anyone is 
unhappy with this resolution to ISSUE-4, please let us know.

Lee
Received on Monday, 31 August 2009 05:46:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:08:26 GMT