This test tries to show what happens during variable substitution when an EXISTS filter pattern with a sub-query is evaluated. The results from running it under both ARQ and RDF::Query contradict my understanding of how SPARQL filter and EXISTS evaluation are meant to occur.
<x> <seq> 2 ;
<even> 2, 4 .
<y> <seq> 5 ;
<even> 2, 4, 6 .
# Find all ?s that have a <seq> value that is equal to the
# number of <even> values belonging to that ?s
SELECT ?s WHERE {
?s <seq> ?value .
FILTER EXISTS {
?s <seq> ?count
{
SELECT (COUNT(*) AS ?count) WHERE {
?s <even> ?other
}
}
}
}
Based on variable substitution for EXISTS, I expect both appearances of ?s
in the EXISTS
pattern to be replaced during filtering. However, the results from existing implementations seems to confict with this interpretation, instead indicating that they are evaluating the aggregation without variable substitution (getting a ?count
value of 5
instead of 2
and 3
(for ?s=<x>
and ?s=<y>
, respectively).
-------
| s |
=======
| <x> |
-------
-------
| s |
=======
| <y> |
-------
Jeen -- I think Andy and I agree that you're following the spec, but that what ended up in the spec might not have been the original intention (and it seems many implementations diverge from the spec text in this case).