rdflib: Problem with nested FILTER NOT EXISTS statements
The following query:
PREFIX ex: <http://www.example.de#>
SELECT ?a ?b WHERE {
?a ex:rel ?b
FILTER NOT EXISTS {
?a ex:rel ?b.
FILTER NOT EXISTS {?c ex:rel2 ?b.}
}
}
should not deliver any results on this single triple (because it lacks a triple binding for ?c ex:rel2 ?b).:
@prefix ex: <http://www.example.de#>.
ex:a ex:rel ex:b.
In contrast, however, it should deliver results on the complete set of triples:
@prefix ex: <http://www.example.de#>.
ex:a ex:rel ex:b.
ex:c ex:rel2 ex:b.
The problem is that rdflib (also the new 4.2.2 version which fixed a similar issue #615 ) in my test delivers a result in both cases. It seems to me that the two nested FILTER statements are not evaluated correctly:
data loaded
Triples: 1
(rdflib.term.URIRef(u'http://www.example.de#a'), rdflib.term.URIRef(u'http://www.example.de#rel'), rdflib.term.URIRef(u'http://www.example.de#b'))
--------------------------------------------------------------------------------
PREFIX ex: <http://www.example.de#>
SELECT ?a ?b WHERE {
?a ex:rel ?b
FILTER NOT EXISTS {
?a ex:rel ?b.
FILTER NOT EXISTS {?c ex:rel2 ?b.}
}
}
OUTPUT:
number of results:1
(rdflib.term.URIRef(u'http://www.example.de#a'), rdflib.term.URIRef(u'http://www.example.de#b'))
Nested filter statements are very important for checking completeness of a dataset. Is there a way to fix this?
simon
About this issue
- Original URL
- State: open
- Created 10 years ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- test: Start tests for nested FILTER statements (#709) This patch adds a single test, self-authored, recreating an issue I encountered when attempting to use a query with a nested `FILTER NOT EXISTS` ... — committed to ajnelson-nist/rdflib by ajnelson-nist 4 years ago
- test: Start tests for nested FILTER statements (#709) This patch adds a single test, self-authored, recreating an issue I encountered when attempting to use a query with a nested `FILTER NOT EXISTS` ... — committed to ajnelson-nist/rdflib by ajnelson-nist 4 years ago
- test: Start tests for nested FILTER statements (#709) This patch adds a single test, self-authored, recreating an issue I encountered when attempting to use a query with a nested `FILTER NOT EXISTS` ... — committed to ajnelson-nist/rdflib by ajnelson-nist 4 years ago
- Deactivate shape until nested FILTERs issue is resolved No effects were observed on Make-managed files. References: * https://github.com/RDFLib/rdflib/issues/709 Signed-off-by: Alex Nelson <alexand... — committed to casework/CASE-Corpora by ajnelson-nist 4 years ago
- test: Add nested FILTER statement test (#709) @mgberg wrote the graph and query for this test last year. This patch puts his work, with his permission, into the new test. This test is known to curr... — committed to ajnelson-nist/rdflib by ajnelson-nist 4 years ago
- test: Start tests for nested FILTER statements (#709) This patch adds a single test, self-authored, recreating an issue I encountered when attempting to use a query with a nested `FILTER NOT EXISTS` ... — committed to mgberg/rdflib by ajnelson-nist 4 years ago
- test: Add nested FILTER statement test (#709) @mgberg wrote the graph and query for this test last year. This patch puts his work, with his permission, into the new test. This test is known to curr... — committed to mgberg/rdflib by ajnelson-nist 4 years ago
- Fix bug preventing nested FILTER statements from working (#709) (#2822) * test: Start tests for nested FILTER statements (#709) This patch adds a single test, self-authored, recreating an issue I ... — committed to RDFLib/rdflib by mgberg 2 years ago
Thanks for the quick response. The fix looks very promising. (I was testing out ways to circumvent using the “filter not exists” statement to check whether this also occurs when using nested bound statements and it seemed to be having similar issues to the “filter not exists” statements. So the “elif graphPattern.translated:” should also solve these nested and filtered bound statements I was experimenting with.) Thanks!