Skip to content

Conversation

@joka921
Copy link
Member

@joka921 joka921 commented Oct 21, 2025

…cification

This commit implements a new operation type ExternallySpecifiedValues that allows specifying values externally via the SERVICE ql:external-values-#id# syntax. The implementation includes:

  • ExternallySpecifiedValues operation: Extends Values class with an identifier field. Always returns knownEmptyResult() as false and is uncachable to ensure values can be modified externally.

  • ExternalValuesQuery parser: New MagicServiceQuery subclass that extracts the identifier from the service IRI and parses variable specifications from the SERVICE body.

  • Parser integration: Updated SparqlQleverVisitor to recognize and parse SERVICE ql:external-values-#identifier# patterns into ExternalValuesQuery operations.

  • Query planner support: Added visitExternalValues to handle ExternalValuesQuery in the query planning phase, creating ExternallySpecifiedValues operations with initially empty values.

  • Operation.cloneAndGetExternalValues(): New method that clones an operation tree and collects all ExternallySpecifiedValues operations, enabling external modification of values.

The implementation follows the existing patterns for magic service queries (PathQuery, SpatialQuery, TextSearchQuery) and integrates cleanly with the existing infrastructure.

🤖 Generated with Claude Code

joka921 and others added 4 commits October 21, 2025 14:19
…cification

This commit implements a new operation type `ExternallySpecifiedValues` that
allows specifying values externally via the SERVICE ql:external-values-#id#
syntax. The implementation includes:

- **ExternallySpecifiedValues operation**: Extends Values class with an
  identifier field. Always returns knownEmptyResult() as false and is
  uncachable to ensure values can be modified externally.

- **ExternalValuesQuery parser**: New MagicServiceQuery subclass that
  extracts the identifier from the service IRI and parses variable
  specifications from the SERVICE body.

- **Parser integration**: Updated SparqlQleverVisitor to recognize and
  parse SERVICE ql:external-values-#identifier# patterns into
  ExternalValuesQuery operations.

- **Query planner support**: Added visitExternalValues to handle
  ExternalValuesQuery in the query planning phase, creating
  ExternallySpecifiedValues operations with initially empty values.

- **Operation.cloneAndGetExternalValues()**: New method that clones an
  operation tree and collects all ExternallySpecifiedValues operations,
  enabling external modification of values.

The implementation follows the existing patterns for magic service queries
(PathQuery, SpatialQuery, TextSearchQuery) and integrates cleanly with the
existing infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
This commit addresses the following improvements:

1. **Add uniqueness check for variables**: Added AD_CONTRACT_CHECK in
   QueryPlanner::visitExternalValues to ensure all variables in an
   external values query are unique.

2. **Simplify getExternalValues interface**: Changed from
   cloneAndGetExternalValues (which cloned the tree) to getExternalValues
   (which only collects pointers). The new method:
   - Returns void instead of unique_ptr<Operation>
   - Does not clone the operation tree
   - Simply traverses and collects ExternallySpecifiedValues pointers

3. **Add updateValues method**: Implemented updateValues() in
   ExternallySpecifiedValues that:
   - Accepts new SparqlValues
   - Asserts that variables remain the same
   - Updates the stored values
   - Made parsedValues_ protected in base class Values to enable this

These changes improve the API design and add necessary safety checks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
This commit adds three test files covering all aspects of the external
values functionality:

1. **ExternallySpecifiedValuesTest.cpp**: Tests for the operation class
   - Basic methods (identifier, knownEmptyResult, caching)
   - knownEmptyResult always returns false even with empty values
   - computeResult functionality
   - updateValues method with valid and invalid inputs
   - Clone functionality
   - getExternalValues collection

2. **ExternalValuesQueryTest.cpp**: Tests for the parser class
   - Identifier extraction from valid and invalid IRIs
   - addParameter with variables
   - Error handling for non-variable objects
   - Error handling for unknown predicates

3. **ExternalValuesIntegrationTest.cpp**: End-to-end integration tests
   - Parsing SERVICE ql:external-values clauses
   - Query planner creates ExternallySpecifiedValues operations
   - Updating values and executing queries
   - Duplicate variable detection
   - getExternalValues with nested operations (UNION)

These tests follow the patterns from existing test files like ValuesTest.cpp
and PathSearchTest.cpp, ensuring consistency with the codebase testing style.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

1 participant