Re: example in current cand. rec....

-------- Original Message --------
 > From: Axel Polleres <>
 > Date: 5 July 2007 14:35
 >
 > referring to the examples in Section 12.2.2 of
 > http://www.w3.org/TR/2007/CR-rdf-sparql-query-20070614/
 >
 > 2 issues:
 >
 > 1) What happened here?
 > ---------
 > Example: group consisting of a basic graph pattern and an optional graph
 > pattern:
 > { ?s :p1 ?v1 OPTIONAL {?s :p2 ?v2 } }
 > LeftJoin(
 >      Join(Z, BGP(?s :p1 ?v1)),
 >      Join(Z, BGP(?s :p1 ?v1)) ),
 >      true)
 > LeftJoin(BGP(?s :p1 ?v1), BGP(?s :p2 ?v2), true)
 > ---------
 >
 > ---------
 > Example: group consisting of a basic graph pattern and an optional
 > graph pattern with a filter:
 >
 > { ?s :p1 ?v1 OPTIONAL {?s :p2 ?v2 FILTER(?v1<3) } }
 >
 > LeftJoin(
 >       Join(Z, BGP(?s :p1 ?v1)),
 >       Join(Z, BGP(?s :p1 ?v1)),
 >       (?v1<3) )
 > LeftJoin(
 >      BGP(?s :p1 ?v1) ,
 >      BGP(?s :p2 ?v2) ,
 >     (?v1<3) )
 > -----------
 >
 > these two examples seem to have some copy-paste-errors, yes?

Some of the examples show two forms of the algebra with and without the
empty graph removal step as noted at the start of 12.2.2:

"""The second form of a rewrite example is the first with empty group
joins removed by step 5."""

We could change the styling to make this clearer.

 >
 > 2) Another question concerning FILTERs in OPTIONALS (I checked this
 > with http://www.sparql.org/validator.html)
 >
 > Please just verify: It is indeed true that
 >
 > SELECT ?N ?M WHERE { ?X foaf:name ?N . ?X :age ?Age .
 > OPTIONAL { ?X foaf:mbox ?M. FILTER(?Age > 30) } }
 >
 >
 > is equivalent to
 >
 > SELECT ?N ?M WHERE { ?X foaf:name ?N . ?X :age ?Age .
 > OPTIONAL { { ?X foaf:mbox ?M. FILTER(?Age > 30) } } }

They are equivalent but the reason may not be straight forward.

The inner most ?X foaf:mbox ?M. FILTER(?Age > 30) becomes:

(filter (> ?Age 30)
         (BGP [triple ?X :foaf#mbox ?M]))

a group of one element, say group(A), becomes join(Z, A) which is turned
into A (step 5).  So groups of one element are eliminated in the query string 
to algebra rewrite process.  That brings the filter within the condition of 
the LeftJoin.

 >
 > but
 >
 > SELECT ?N ?M WHERE { ?X foaf:name ?N . ?X :age ?Age .
 > OPTIONAL { ?X foaf:name ?N . { ?X foaf:mbox ?M. FILTER(?Age > 30) } }
}
 >
 > is not semantically equivalent, yes?

It is a different algebra expression; specifically, it does not place the 
filter in the LeftJoin condition.

 > I am asking, because I originally also thought the second variant would
 > treat the FILTER local to ist group graph pattern

Thank you for your comments,

	Andy

 >
 > thanks & best regards,
 > axel
 >
 >
 >
 > --
 > Dr. Axel Polleres
 > email: axel@polleres.net  url: http://www.polleres.net/

Received on Sunday, 8 July 2007 18:03:49 UTC