W3C home > Mailing lists > Public > public-sparql-dev@w3.org > April to June 2016

Re: can subqueries be executed first in SPARQL?

From: Peter F. Patel-Schneider <pfpschneider@gmail.com>
Date: Fri, 17 Jun 2016 05:18:27 -0700
To: james anderson <james@dydra.com>, public-sparql-dev@w3.org
Message-ID: <47d85c54-a08d-2fb5-73ec-b9cd7f7209a3@gmail.com>
On 06/17/2016 05:01 AM, james anderson wrote:
> good afternoon;
> 
>> On 2016-06-17, at 13:16, Peter F. Patel-Schneider <pfpschneider@gmail.com
>> <mailto:pfpschneider@gmail.com>> wrote:
>>
>>> On 17 Jun 2016, at 03:58, james anderson <james@dydra.com
>>> <mailto:james@dydra.com>> wrote:
>>>
>>> good morning;
>>>
>>>> On 2016-06-17, at 01:11, Peter F. Patel-Schneider <pfpschneider@gmail.com
>>>> <mailto:pfpschneider@gmail.com>>
>> wrote:
>>>>
>> [...]
>>> given this form:
>>>
>>> Input:
>>>
>>> 1 SELECT ?x WHERE {
>>> 2    ?x a ?y .
>>> 3    FILTER EXISTS {
>>> 4      SELECT ?z WHERE { ?z ?w ?v . FILTER sameTerm(?x,?y) }
>>> 5    }
>>> 6  }
>>>
>>> Algebra structure:
>>>
>>> 1 (base <http://example/base/>
>>> 2   (project (?x)
>>> 3     (filter (exists
>>> 4                (project (?z)
>>> 5                  (filter (sameTerm ?x ?y)
>>> 6                    (bgp (triple ?z ?w ?v)))))
>>> 7       (bgp (triple ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
>> ?y)))))
>>>
>>> why would the result change were the project evaluated logically later?
>>>
>>> best regards, from berlin,
>>> ---
>>> james anderson | james@dydra.com <mailto:james@dydra.com> | http://dydra.com
>>
>> Evaluating the project first results in an empty solution sequence because x
>> and y are unbound.  Evaluating the project after an exists substitution will
>> result in a solution sequence with a solution mapping binding z for each
>> triple in the active graph if x and y were bound to the same term.
> 
> “bound to the same term”, how?

Aah.  I used "bound" where SPARQL uses "maps".  That's showing my background
in logic.

> ---
> james anderson | james@dydra.com <mailto:james@dydra.com> | http://dydra.com> 

Evaluate the above against the graph (with the same base)
  :k a :k .
  :j a :k .
The bgp evaluation results in a multiset with two solution mappings
{ { (x,k), (y,k) }, { (x,j), (y,k) } }
The first produces a non-empty value for the project whereas the second
produces an empty value.

peter
Received on Friday, 17 June 2016 12:18:59 UTC

This archive was generated by hypermail 2.3.1 : Friday, 17 June 2016 12:19:00 UTC