https://issues.apache.org/jira/browse/JENA-1963

Try

sparql --strict
sparql --engine=ref
sparql --optimize=off

The optimization rule that sees "FILTER(?n = ?m)" and tries to make it a join goes wrong because of the interaction with substitution.

BTW:
https://afs.github.io/substitute.html

lists several problems with NOT EXISTS and gives a solution.

The solution would also work for parameterized queries if the scope-renaming is omitted.

    Andy

On 03/05/2021 16:43, Olivier Dameron wrote:
Dear jena users,
   I tried to replicate the negation examples from https://www.w3.org/TR/sparql11-query/#idp899488 (section 8.3.3 Examples: Inner FILTERs). I got [(a, 1), (b, 3.0)] for both versions of the query whereas I expected to get only [(b, 3.0)] with the FILTER NOT EXISTS.

Same result with jena-3.17
Rdflib returns the same results as the W3C page.

Am I missing something?
Thank you
olivier


DATA:
-----
@prefix : <http://example.com/> .

:a :p :v1 .
:a :q :v1 .
:a :q :v2 .

:b :p :v3 .
:b :q :v4 .
:b :q :v5 .



QUERY 1 (expected: [(b, 3.0)] ; returned: [(a, 1), (b, 3.0)]):
--------------------------------------------------------------
PREFIX : <http://example.com/>

SELECT *
WHERE {
   ?x :p ?n .
   FILTER NOT EXISTS {
     ?x :q ?m .
     FILTER(?n = ?m)
   }
}


QUERY 2 (correctly returned [(a, 1), (b, 3.0)]):
------------------------------------------------
PREFIX : <http://example.com/>

SELECT *
WHERE {
   ?x :p ?n .
   MINUS {
     ?x :q ?m .
     FILTER(?n = ?m)
   }
}

Reply via email to