Summary
Enforce SPARQL 1.1 blank node scope validation during parsing and semantic analysis. According to W3C SPARQL 1.1 (§5.1.1 & §4.1.4), a blank node label (e.g. _:a) is scoped strictly to a single Basic Graph Pattern (BGP). Reusing the same label across disjoint BGPs (e.g. across UNION, OPTIONAL, GRAPH, or separate pattern blocks) is a syntax/scope violation and must be rejected.
Target Branch
- Branch:
feature/corese-next
Specification & Semantics
# VALID: same label reused within the same BGP
SELECT * WHERE {
_:a :p ?x .
_:a :q ?y .
}
# INVALID: same label reused across distinct BGPs
SELECT * WHERE {
{ _:a :p ?x }
UNION
{ _:a :q ?y }
}
Technical Context & Implementation Notes
- BGP Tracking:
SparqlAstBuilder.java already defines enterBgp() / exitBgp().
- In
termFromBlankNode(SparqlParser.BlankNodeContext ctx), blank node labels are currently collected globally in blankNodeLabels without tracking their declaring BGP.
- Scope Validation:
- Implement validation (either during AST construction or via a
BlankNodeScopeValidationRule in fr.inria.corese.core.next.query.impl.sparql.parser.semantic.rule).
- Reject with
QuerySyntaxException / QueryValidationException when a label appears in more than one distinct BGP.
Targeted W3C SPARQL 1.0 / 1.1 Test Cases
syn-bad-UNION-breaks-BGP
syn-bad-OPT-breaks-BGP
syn-bad-GRAPH-breaks-BGP
syn-blabel-cross-union-bad
syn-blabel-cross-optional-bad
syn-blabel-cross-graph-bad
syn-bad-34.rq through syn-bad-38.rq
Verification
- Unit tests (
corese-core):
./gradlew test --tests "fr.inria.corese.core.next.query.impl.sparql.parser.SparqlParserValidationTest"
- W3C conformance (
corese-w3c):
./gradlew test --tests "fr.inria.corese.w3c.sparql10.Sparql10DynamicTest"
Acceptance Criteria
Summary
Enforce SPARQL 1.1 blank node scope validation during parsing and semantic analysis. According to W3C SPARQL 1.1 (§5.1.1 & §4.1.4), a blank node label (e.g.
_:a) is scoped strictly to a single Basic Graph Pattern (BGP). Reusing the same label across disjoint BGPs (e.g. acrossUNION,OPTIONAL,GRAPH, or separate pattern blocks) is a syntax/scope violation and must be rejected.Target Branch
feature/corese-nextSpecification & Semantics
Technical Context & Implementation Notes
SparqlAstBuilder.javaalready definesenterBgp()/exitBgp().termFromBlankNode(SparqlParser.BlankNodeContext ctx), blank node labels are currently collected globally inblankNodeLabelswithout tracking their declaring BGP.BlankNodeScopeValidationRuleinfr.inria.corese.core.next.query.impl.sparql.parser.semantic.rule).QuerySyntaxException/QueryValidationExceptionwhen a label appears in more than one distinct BGP.Targeted W3C SPARQL 1.0 / 1.1 Test Cases
syn-bad-UNION-breaks-BGPsyn-bad-OPT-breaks-BGPsyn-bad-GRAPH-breaks-BGPsyn-blabel-cross-union-badsyn-blabel-cross-optional-badsyn-blabel-cross-graph-badsyn-bad-34.rqthroughsyn-bad-38.rqVerification
corese-core):corese-w3c):Acceptance Criteria
UNION,OPTIONAL,GRAPH, or disjoint BGPs is rejected.syn-bad-*andsyn-blabel-*tests pass inSparql10DynamicTest.