Fix bug preventing nested FILTER statements from working (#709) by mgberg · Pull Request #2822 · RDFLib/rdflib (original) (raw)
Summary of changes
Disclaimer: I am not super familiar with the SPARQL algebra/translation code in RDFLib, so I'm not confident this is the best solution. Also I'm not 100% confident this will solve all nested filter issues.
This fixes an issue which allows nested filters to work as discussed in #709. Previously, a graph pattern could be passed to rdflib.plugins.sparql.algebra::translateGroupGraphPattern
multiple times. If this occurs, the graph pattern would get overwritten with an empty pattern, causing the nested filters to appear to be dropped in the query plan. This modifies translateGroupGraphPattern
to:
- Mark translated graph patterns as translated, and
- Simply return the provided graph pattern if it already has been translated.
Additionally, this includes two new test cases compiled by @ajnelson-nist that verifies that known nested filter issues work (at least those discussed in #709).
Checklist
- Checked that there aren't other open pull requests for
the same change. - Checked that all tests and type checking passes.
- If the change adds new features or changes the RDFLib public API:
- Created an issue to discuss the change and get in-principle agreement.
- Considered adding an example in
./examples
.
- If the change has a potential impact on users of this project:
- Added or updated tests that fail without the change.
- Updated relevant documentation to avoid inaccuracies.
- Considered adding additional documentation.
- Considered granting push permissions to the PR branch,
so maintainers can fix minor issues and keep your PR up to date.