- From: Peter F. Patel-Schneider <pfpschneider@gmail.com>
- Date: Thu, 23 Jun 2016 13:20:11 -0700
- To: Eric Prud'hommeaux <eric@w3.org>
- Cc: RDF Data Shapes Working Group <public-data-shapes-wg@w3.org>
Here is a situation where the SPARQL 1.1 Query recommendation,
https://www.w3.org/TR/2013/REC-sparql11-query-20130321/, says something
clearly, unambiguously, and unproblematically but the result is
counterintuitive.  At least some SPARQL implementations diverge from the
SPARQL specification here, and it is entirely possible that all major SPARQL
implementations do.
Consider the query
  prefix ex: <http://www.example.org/>
  SELECT ?this WHERE {
 ?this ex:p ?value .
 FILTER NOT EXISTS { ?value ex:q ex:d } .
  }
and the graph
  @prefix ex: <http://www.example.org/> .
  ex:b ex:p _:v .
  ex:c ex:q ex:d .
According to the SPARQL 1.1 Query recommendation there will be no results
from evaluating this query on this graph.  This happens because the
definition of EXISTS is via substitution, which ends up producing
  BCP( _:v ex:q ex:d )
which then matches against the ex:c ex:q ex:d triple because the _:v can be
mapped to ex:c by the RDF instance mapping that is part of SPARQL pattern
instance mappings.
No semantic anomalies happen during the evaluation of this query according
to the SPARQL 1.1 Query recommendation.
This is not an unusual use of SPARQL and is a core use of EXISTS in SPARQL.
Peter F. Patel-Schneider
Nuance Communications
Received on Thursday, 23 June 2016 20:20:45 UTC