Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug preventing nested FILTER statements from working (#709) #2822

Merged
merged 6 commits into from
Jul 24, 2024

Conversation

mgberg
Copy link
Contributor

@mgberg mgberg commented Jul 11, 2024

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:

  1. Mark translated graph patterns as translated, and
  2. 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.

ajnelson-nist and others added 2 commits July 11, 2024 09:43
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` statement.

This test is known to currently fail, but is expected to pass as written
with a corrected implementation.

References:
* RDFLib#709

Signed-off-by: Alex Nelson <[email protected]>
@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 currently fail, but is expected to pass as written
with a corrected implementation.

References:
* RDFLib#709 (comment)

Co-authored-by: Matt Goldberg <[email protected]>
Signed-off-by: Alex Nelson <[email protected]>
@ajnelson-nist
Copy link
Contributor

Thank you for nudging this forward, @mgberg .

@coveralls
Copy link

coveralls commented Jul 11, 2024

Coverage Status

coverage: 91.041% (+0.001%) from 91.04%
when pulling 958ffb4 on mgberg:issue-709
into a7865e9 on RDFLib:main.

@nicholascar
Copy link
Member

Hi @ajnelson-nist & @mgberg,

Thanks for this and similar PRs. We are about to unblock this long list of auto-PRs from dependabot etc. and will merge this in after doing that. Will also make a 7.10 release. ETA: by August.

@ashleysommer
Copy link
Contributor

Merge blockages should be unblocked now. I've merged latest main branch into this PR, and hopefully everything passes.

@ashleysommer ashleysommer merged commit 6c5a783 into RDFLib:main Jul 24, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants