Re: quick sanity check question on sub-query, service and variable scoping

good evening;

> On 2015-10-19, at 21:15, Gary King <gwking@metabang.com> wrote:
> 
> Hi Miguel,
> 
>> SERVICE blocks and sub-queries have different semantics relating to the variable scope.
> 
> — snip —
> 
> At first I thought your answer made sense but further reflection (and Gregory Williams) answer brings me back to my initial impression.
> 
> Indeed, even in a query like:
> 
> select * {
>   # A
>   {
>    values ?x { 1 2 3 }
>   }
>  # B
>   {
>     values ?y { 1 2 3 }
>       filter( ?y > ?x)
>   }
> }
> 
> A and B should be evaluated independently and ?x is not bound in the scope of B so the query should return no results.

you need to keep three things separate: the binding, which introduces the scope, operators which propagate that scope, and projections which limit it.
a service clause always has a ‘*’ projection for the outer form, but it may have others for inner forms.
other operators, such as filters, just refer to variables.

for the example above, for which sparql.org indicates the following algebra:

 1 (base <http://example/base/>
  2   (join
  3     (table (vars ?x)
  4       (row [?x 1])
  5       (row [?x 2])
  6       (row [?x 3])
  7     )
  8     (filter (> ?y ?x)
  9       (table (vars ?y)
 10         (row [?y 1])
 11         (row [?y 2])
 12         (row [?y 3])
 13       ))))

for the filtered ?x no binding introduces a scope which covers the operator
similar situations apply to the sub-select and service cases.
whether the projection is ‘*’ or limited does not affect whether a binding introduces a scope.

best regards, from berlin,



---
james anderson | james@dydra.com | http://dydra.com

Received on Monday, 19 October 2015 19:40:42 UTC