problem with blank nodes in EXISTS solution mappings

The definition of EXISTS in SPARQL 1.1 Query uses the substitute function.
There are multiple problems with substitute already reported.  Here is
another one.


Consider

SELECT ?x WHERE {
  :s :p ?x .
  FILTER EXISTS { ?x :p ?y . }
}

on the graph

:s :p _:x .

The EXISTS gets { { (x,_:x) } } and then does a substitute which results in
  BGP( _:x :p ?y )
This has a solution of
  { { (y,:x) } }
because the blank node that is the mapping of x can itself be further mapped
to :s in the RDF instance mapping part of a pattern instance mapping.

So the result of the SELECT is
  { { ( x, _:x ) } }
which is not at all what should be expected.

This seems to be a severe problem for the substitution definition of EXISTS.


I suggest that the substitution definition of EXISTS be replaced with a
definition that uses initial (multisets of) solution mappings.  This would
solve the problems with substitution into BIND, VALUES, and SELECT
variables.


Peter F. Patel-Schneider
Nuance Communications

Received on Thursday, 16 June 2016 22:38:32 UTC