Skip to content

feat: allow AS-bound variable references#142

Draft
jitsedesmet wants to merge 2 commits into
mainfrom
fix/fix-reuse-of-vars
Draft

feat: allow AS-bound variable references#142
jitsedesmet wants to merge 2 commits into
mainfrom
fix/fix-reuse-of-vars

Conversation

@jitsedesmet
Copy link
Copy Markdown
Member

Add support for referencing variables bound by preceding (expr AS ?var) expressions in subsequent SELECT expressions, per the updated SPARQL spec (w3c/sparql-query#380, w3c/rdf-tests#340).

The query SELECT (COUNT(?v) AS ?count) (?count + 1 AS ?countPlusOne) ... was previously rejected with 'Use of ungrouped variable' because the validator did not recognize that ?count was in scope from an earlier AS binding.

Changes:

  • Fix queryProjectionIsGood validation to track AS-bound variables and allow their use in subsequent projection expressions
  • Add select-variable-reuse test with AST, algebra, and generator statics

…rences

Add support for referencing variables bound by preceding (expr AS ?var)
expressions in subsequent SELECT expressions, per the updated SPARQL spec
(w3c/sparql-query#380, w3c/rdf-tests#340).

The query `SELECT (COUNT(?v) AS ?count) (?count + 1 AS ?countPlusOne) ...`
was previously rejected with 'Use of ungrouped variable' because the
validator did not recognize that ?count was in scope from an earlier
AS binding.

Changes:
- Fix queryProjectionIsGood validation to track AS-bound variables and
  allow their use in subsequent projection expressions
- Add select-variable-reuse test with AST, algebra, and generator statics

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jitsedesmet
Copy link
Copy Markdown
Member Author

@rubensworks should this be changed in the 1.1 parser also? Or is this 1.2 specific?

@rubensworks
Copy link
Copy Markdown
Member

1.2 is fine.

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.

2 participants