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

can subqueries be executed first in SPARQL?

From: Peter F. Patel-Schneider <pfpschneider@gmail.com>
Date: Thu, 16 Jun 2016 14:36:49 -0700
To: public-sparql-dev@w3.org
Message-ID: <77366e7a-45ec-d665-535c-c42c6690769a@gmail.com>
https://www.w3.org/TR/sparql11-query/#subqueries says

Due to the bottom-up nature of SPARQL query evaluation, the subqueries are
evaluated logically first, and the results are projected up to the outer query.

I think that this is incorrect.  For example, in

SELECT ?x WHERE {
  ?x :a :b .
  FILTER EXISTS {
    SELECT ?x WHERE { ?x :a :b } HAVING ( COUNT(*) = 1 )
    }
  }

The inner select is not even known until the bindings for ?x in the outer
query have been determined because EXISTS uses substitution into the inner
query.  (Whether that is a good idea or not is a separate issue.)

I ran into this issue when reading https://scirate.com/arxiv/1606.01441
I believe that the sentence I quote above is the one that the authors indicate
that Fuseki and Blazegraph are using to support their implementation of
subqueries inside EXISTS.



I suggest that there be an erratum removing this sentence.


Peter F. Patel-Schneider
Nuance Communications
Received on Thursday, 16 June 2016 21:37:19 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 16 June 2016 21:37:20 UTC