On Oct 19, 2015, at 11:26 AM, Miguel <miguel.ceri...@gmail.com> wrote: > > Hi Gary, > SERVICE blocks and sub-queries have different semantics relating to the > variable scope. > > The variables in a sub-query are in a scope disjoint from the enclosing one, > unless they are projected in the SELECT clause. > So in the first example the variable ?time1 in the sub-query is distinct from > the variable ?time1 in the main query. > In this case you are correct, the inner ?time1 won't never be bound. > > The variables in a SERVICE blocks instead, share the same scope as the > enclosing query. > So in the second example there is only a ?time1 variable, referenced both > inside and outside the SERVICE block. > In this case ?time1 main perfectly be bound. > Of course, if it is actually bound or not depends on the data.
I don’t think this is right. The bottom-up semantics of SERVICE (and SPARQL in general) means that the service block will be evaluated independently, and then joined with any results from the basic graph pattern that precedes it. >> select distinct * { >> ?person a ex:Person . >> ?person ex:startTime ?time1 . >> >> service <http://example.com/foo> { >> ?otherPerson a ex:Person . >> ?otherPerson ex:startTime ?time2 . >> FILTER (?time2 > ?time1) >> } >> } > Based on the description of “ Evaluation of a Service Pattern”[1]: """ ...the multiset of solution mappings corresponding to the results of executing query SELECT * WHERE Q against the service endpoint with IRI iri where Q is the serialization of P in SPARQL syntax, in case of a successful service invocation according to the SPARQL protocol... """ the evaluation here is going to send the SPARQL query: SELECT * WHERE { ?otherPerson a ex:Person . ?otherPerson ex:startTime ?time2 . FILTER (?time2 > ?time1) } to the endpoint at <http://example.com/foo>. And since this query will always have ?time1 unbound at the point of evaluation, no results will be returned. .greg [1] http://www.w3.org/TR/2013/REC-sparql11-federated-query-20130321/#algebra_service