sparql-view-unfold
    Preparing search index...

    Module sparql-view-unfold

    View unfolding and query optimisation for SPARQL 1.2.

    Rewrites a SPARQL 1.2 query posed over views into an equivalent query over the data those views are defined on.

    A mapping is one or more SPARQL CONSTRUCT queries defining a view: the template (head) says which triples the view holds, the WHERE clause (body) how they are found in the data. A pipeline of transformations is then run over the user query, the first of which unfolds that mapping into every triple pattern and the rest of which optimise what comes out.

    Running SPARQL 1.2 queries - triple terms and all - against RDF 1.1 data is the case this was built for: a view then says how RDF 1.1 data represents RDF 1.2, and the rewrite hands back plain SPARQL 1.1.

    This entry point is platform-neutral, and is kept that way deliberately: the one transformation needing a Comunica runtime is reached through the sparql-view-unfold/comunica subpath instead, because re-exporting it here would put node:module and node:path in every consumer's module graph. See the Comunica entry point for why a bundler cannot shake that back out.

    https://w3c.github.io/rdf-interop/spec/ RDF 1.2 Interoperability Spec

    import {
    createQueryRewriter,
    filterFalseTransformation,
    mappingFromConstructQueries,
    unfoldingTransformation,
    } from 'sparql-view-unfold';

    const rewriter = createQueryRewriter([
    unfoldingTransformation(mappingFromConstructQueries([
    'CONSTRUCT { ?t rdf:reifies <<( ?s ?p ?o )>> } WHERE { ... RDF 1.1 pattern ... }',
    ])),
    filterFalseTransformation(),
    ]);
    const sparql11Query = await rewriter.rewriteQuery('SELECT * WHERE { ?x rdf:reifies <<( ?s ?p ?o )>> }');

    References

    createDefaultTransformationPipeline → createDefaultTransformationPipeline
    createQueryRewriter → createQueryRewriter
    DT_INTERNAL_BNODE → DT_INTERNAL_BNODE
    extendsToValuesTransformation → extendsToValuesTransformation
    EXTENSION_FUNCTION_BNODE → EXTENSION_FUNCTION_BNODE
    filterFalseTransformation → filterFalseTransformation
    internalBnodeAsSpecialIriTransformation → internalBnodeAsSpecialIriTransformation
    internalBnodeAsSpecialLiteralTransformation → internalBnodeAsSpecialLiteralTransformation
    IRI_PREFIX_BNODE → IRI_PREFIX_BNODE
    joinValuesToFilterTransformation → joinValuesToFilterTransformation
    Mapping → Mapping
    mappingFromConstructQueries → mappingFromConstructQueries
    MappingHead → MappingHead
    MappingOptions → MappingOptions
    nullifyJoinOverIncompatibleBoundsTransformation → nullifyJoinOverIncompatibleBoundsTransformation
    nullifyUnbindableVarsTransformation → nullifyUnbindableVarsTransformation
    pullUpExtendsTransformation → pullUpExtendsTransformation
    pushDownAssertionsTransformation → pushDownAssertionsTransformation
    QueryRewriter → QueryRewriter
    QueryTransformation → QueryTransformation
    removeProjectionsTransformation → removeProjectionsTransformation
    rewriteNonRecursivePathsTransformation → rewriteNonRecursivePathsTransformation
    serviceCallPushUpTransformation → serviceCallPushUpTransformation
    TransformationContext → TransformationContext
    UnfoldingOptions → UnfoldingOptions
    unfoldingTransformation → unfoldingTransformation
    VAR_PREFIX_MAPPING → VAR_PREFIX_MAPPING
    VAR_PREFIX_MERGED_HEAD → VAR_PREFIX_MERGED_HEAD
    VAR_PREFIX_USER_QUERY → VAR_PREFIX_USER_QUERY