fix(sparql): return no solutions for a GROUP BY with no matches - #3498
Open
Sanjays2402 wants to merge 1 commit into
Open
fix(sparql): return no solutions for a GROUP BY with no matches#3498Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
evalAggregateJoin yielded a single empty solution whenever the
aggregation produced zero groups, regardless of whether the query used
GROUP BY. For an explicit GROUP BY that matches nothing there are zero
groups, so the result must be empty, but rdflib reported a malformed row
with no variable bindings (Result.bindings == [{}]).
Only yield that fallback row for an implicit (ungrouped) aggregate,
where SPARQL does require exactly one solution.
Adds regression tests for both the grouped and ungrouped empty cases.
Closes RDFLib#3382
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3382
Summary of changes
evalAggregateJoinyielded a single empty solution whenever the aggregationproduced zero groups, regardless of whether the query used
GROUP BY. Anexplicit
GROUP BYthat matches nothing has zero groups, so the result must beempty, but rdflib reported a malformed row with no variable bindings:
The fallback row is now only yielded for an implicit (ungrouped) aggregate,
where SPARQL does require exactly one solution. Backwards compatible for every
other case.
Checklist
the same change.
so maintainers can fix minor issues and keep your PR up to date.
test/test_sparql/is green (431 passed), and the two new tests intest/test_sparql/test_agg_undef.pycover both the grouped and ungrouped emptycases. This change was prepared with AI assistance; the regression test was run
locally and fails without the fix.