From: Lee Feigenbaum <lee@thefigtrees.net>

Date: Thu, 25 Oct 2007 16:09:07 -0400

Message-ID: <4720F7E3.9020809@thefigtrees.net>

To: Francis McCabe <frankmccabe@mac.com>

CC: public-rdf-dawg-comments@w3.org

Date: Thu, 25 Oct 2007 16:09:07 -0400

Message-ID: <4720F7E3.9020809@thefigtrees.net>

To: Francis McCabe <frankmccabe@mac.com>

CC: public-rdf-dawg-comments@w3.org

Francis McCabe wrote: > > I am having some trouble reconciling this test with the spec, the > reported results of the query. > > The test reads: > > FILTERs in an OPTIONAL do not extend to variables bound outside of the > LeftJoin(...) operation > > > > however, the spec reads > > Query variables in SPARQL queries have global scope; use of a given > variable name anywhere in a query identifies the same variable. Hi Frank, These two bits of text are compatible. The second piece of text indicates that anywhere that the lexical token ?v appears in a query refers to the same variable. The first piece of text indicates that a FILTER clause in an OPTIONAL only filters solutions with respect to the LeftJoin(...) algebra expression in which it appears. More on this specific example: > > The reported results of the test: > > PREFIX : <http://example/> > > SELECT * > { > :x :p ?v . > { :x :q ?w > OPTIONAL { :x :p ?v2 FILTER(?v = 1) } > } > } > > include the results > > v w [snip] To simplify, note that the results of this test are every possible pair of values for ?v (objects of :p) and ?w (objects of :q). > (My formatting, the XML is illegible by mortals) :-) > However, I think that the test is wrong: v2 should be v. On my budding > implementation, I get the above results only if I change v2 to v. If I > don't, I get: > I believe the test is correct. Here's what happens: After following the algorithm in #convertGraphPattern, the above query corresponds to this algebra expression: Join(BGP(:x :p ?v), LeftJoin(BGP(:x :q ?w), BGP(:x :p ?v2), ?v = 1) The filter (?v = 1) is tied to the LeftJoin. Of course, all of the solutions to Join(BGP(:x :q ?w), BGP(:x :p ?v2)) fail that filter since none of the solutions bind ?v. Therefore, the filter on the LeftJoin rejects all of the "extended" solutions (the solutions composed from both the left-hand and right-hand sides of the OPTIONAL). That means that the solutions to the LeftJoin(...) are just the solutions of the left-hand side: ?w ?v2 --------- 1 unbound 2 unbound 3 unbound The solutions to the other BGP are straightforward ?v -- 1 2 3 4 ...and the conjunction of those two result sets are the results as given in the test suite (the XML result format omits unbound variables) I hope this is helpful. Lee > v v2 w > (4, (null), 3) > > (4, (null), 2) > > (4, (null), 1) > > (3, (null), 3) > > (3, (null), 2) > > (3, (null), 1) > > (2, (null), 3) > > (2, (null), 2) > > (2, (null), 1) > > (1, 4, 3) > > (1, 3, 3) > > (1, 2, 3) > > (1, 1, 3) > > (1, 4, 2) > > (1, 3, 2) > > (1, 2, 2) > > (1, 1, 2) > > (1, 4, 1) > > (1, 3, 1) > > (1, 2, 1) > > (1, 1, 1) > > > Note that optional implies that there will be solutions that do not bind > v2. > > I would appreciate clarification on this matter. > > > > Frank > > > > > >Received on Thursday, 25 October 2007 20:09:26 UTC

*
This archive was generated by hypermail 2.3.1
: Tuesday, 6 January 2015 20:52:09 UTC
*