Skip to content

[Query] Support RDF collection lists and blank node freshness in CONSTRUCT templates #600

Description

@remiceres

Summary

Support compilation and materialization of RDF collection lists ((...)) and ensure blank node identifier freshness per solution mapping in CONSTRUCT templates.

Target Branch

  • feature/corese-next

Specification & Semantics

According to W3C SPARQL 1.1 Query (§16.2):

  • RDF collection syntax ( ?s ?o ) inside a CONSTRUCT template must expand to standard rdf:first and rdf:rest chains terminating with rdf:nil. No additional rdf:type rdf:List triple is required.
  • Blank nodes in a CONSTRUCT template must generate fresh blank node identifiers for each solution mapping in the result sequence.
  • Multiple occurrences of the same blank node label within a single template instance must refer to the same instantiated blank node for that solution, preserving internal graph reification structure.
  • Note: Basic - List 1 tests () inside a SELECT WHERE pattern, which is independent of CONSTRUCT template processing and is tracked separately.

Targeted W3C SPARQL 1.0 / 1.1 Test Cases

  • dawg-construct-reification-1 (Reification of default graph)
  • dawg-construct-reification-2 (Reification of default graph)
  • construct_list (CONSTRUCT { (?s ?o) :prop ?p } WHERE { ?s ?p ?o })

Technical Context & Points to Investigate

  1. In CoreseAstQueryBuilder.java, examine compileConstructTemplate and how RDF collection AST nodes (ListPatternAst or equivalent) are compiled into the template Exp.
  2. In construct result materialization (CoreseGraphQuery.java / ConstructTemplate), verify how blank node terms are allocated: fresh per solution mapping, while caching identity within the same solution mapping.

Acceptance Criteria

[ ] Unit test demonstrating blank node freshness across multiple solutions in a CONSTRUCT query.
[ ] Blank nodes generated in CONSTRUCT instantiate unique identifiers per solution row while preserving internal graph structure.
[ ] RDF collections in construct templates produce valid rdf:first / rdf:rest chains terminating in rdf:nil.
[ ] Targeted W3C construct reification and list tests pass.
[ ] 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