Repository navigation
Treat variables that are not in the pattern as unbound in expressions - #85
Open
MathiasVDA wants to merge 1 commit into
Open
MathiasVDA wants to merge 1 commit into
MathiasVDA wants to merge 1 commit into
Conversation
ORDER BY ?x, BOUND(?x), COALESCE(?x, ...) and FILTER(?x = ...) failed with VariableNotFound when ?x did not occur in the graph pattern. Per SPARQL 1.1 such a variable is unbound in every solution, the same way project() already treats a projected variable that does not exist. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
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.
Requested by Mathias
Fixes #84.
Before: an expression that uses a variable which does not occur in the graph pattern fails the whole query, e.g.
ORDER BY ?noperaisesVariable ?nope not found in context ProjectInner-OrderByExpression(0)-OrderingOperation. The same happens forBOUND(?nope),COALESCE(?nope, ?o)andFILTER(?nope = "a").After: the variable is treated as unbound, as SPARQL 1.1 §18.6 requires.
ORDER BY ?nopekeeps the input order,BOUND(?nope)is false,COALESCEfalls through to the next argument andFILTER(?nope = "a")removes the row.How:
variable()andbound()inlib/query_processing/src/expressions.rsno longer returnVariableNotFound.variable()adds a null column of typeNonefor the expression context, the same wayproject()already handles a projected variable that does not exist, andbound()returnsfalse. The existing null handling in comparisons and functions does the rest.Tests:
py_maplib/tests/test_unbound_variables.pycovers ORDER BY (with and without DISTINCT), BOUND, COALESCE and FILTER. The new tests fail on 0.20.32 and pass with this change;test_basics,test_aggregation_count_zero,test_concat_is_string,test_replace_bindingsandtest_exceptionsstill pass.🤖 Generated with Claude Code