Skip to content

[Query] Enforce default vs named graph separation and variable graph iteration in SPARQL datasets #598

Description

@remiceres

Summary

Ensure queries strictly respect the separation between the active default graph and named graphs in SPARQL dataset clauses (FROM / FROM NAMED), and that GRAPH ?g patterns properly iterate over available named graphs.

Target Branch

  • feature/corese-next

Specification & Semantics

According to W3C SPARQL 1.1 Query (§12 & §13):

  • When a dataset is explicitly defined:
    • Specifying FROM clauses alone leaves the set of named graphs empty; GRAPH ?g or GRAPH <iri> must not match anything and must NOT fall back to storage named graphs.
    • Specifying FROM NAMED clauses alone leaves the default graph empty; triple patterns outside a GRAPH block must evaluate against an empty default graph and must NOT fall back to the storage default graph.
  • Triple patterns outside a GRAPH block must evaluate exclusively against the active default graph.
  • When evaluating GRAPH ?g { ... } where ?g is an unbound variable, execution must iterate over each active named graph defined in the dataset (or storage named graphs if no explicit dataset is defined), binding ?g without matching default graph statements.
  • Queries combining GRAPH with UNION patterns must correctly preserve solutions from each branch.

Targeted W3C SPARQL 1.0 / 1.1 Test Cases

  • graph-02 (Data: named graph / Query: default graph)
  • graph-05 (Data: default and named / Query: default graph)
  • graph-07 (Data: default and named / Query: all data by UNION)
  • graph-08, graph-09, graph-10b, graph-11
  • dataset-09b, dataset-10b
  • Join operator with Graph and Union

Technical Context & Points to Investigate

  1. In StorageManagerProducer.java, examine how active from and from named restrictions are propagated to statement patterns and whether missing restrictions fall back inappropriately to full store contents.
  2. In StorageManagerEdge.java and candidate edge resolution, investigate whether variable graph patterns in GRAPH ?g correctly isolate named graphs from the default graph.
  3. Recommend proceeding incrementally: first isolate and verify default graph scoping (graph-02, graph-05), then address variable iteration and GRAPH-UNION joins in a separate step.

Acceptance Criteria

[ ] Reproducible unit tests demonstrate default graph isolation and named graph scoping.
[ ] Explicit datasets without FROM NAMED leave named graphs empty (no storage fallback).
[ ] Explicit datasets without FROM leave the default graph empty (no storage fallback).
[ ] GRAPH ?g binds exclusively to active named graphs.
[ ] Targeted W3C graph tests pass without regressions on existing passing tests.
[ ] 0 SonarLint issues and cognitive complexity < 15.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

featureNew feature or capabilityw3c-conformanceW3C standards compliance (SPARQL 1.1, Turtle, RDF 1.1)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions