Skip to content

Interface: SparqlTranslation

@kortexya/reasoninglayer


@kortexya/reasoninglayer / SparqlTranslation

Defined in: src/types/sparql.ts:366

The full SPARQL → OSFQL translation of a query, rendered without executing it.

The OSFQL statements (plan fragments unless SparqlTranslation.complete) plus the algebra plan tree and the solution modifiers (DISTINCT, ORDER BY, LIMIT, OFFSET) the query carries. projection is undefined for SELECT *.

const translation = await client.sparql.translateQuery({ query: 'SELECT * WHERE { ?s ?p ?o }' });
console.log(translation.form); // 'select'
if (translation.complete) {
console.log(translation.osfql[0]?.osfql); // the one statement that answers the query
}

complete: boolean

Defined in: src/types/sparql.ts:381

Whether osfql ANSWERS the query when run verbatim.

Check this before running anything. true means osfql holds exactly one statement that carries the whole query (filters, negations, OPTIONALs, aggregation and modifiers), so running it gives the same solutions as client.sparql.executeQuery on the original query. false means osfql is a list of plan FRAGMENTS that the engine’s bridge executes and joins itself: running osfql[0], or all of them in sequence, answers a different question. Some plans (a probe over a variable graph, for example) never fold into one statement, so false is a permanent property of those queries. Run them with executeQuery.


constructTemplate: string[]

Defined in: src/types/sparql.ts:401

Rendered CONSTRUCT template triples (empty unless the form is construct).


distinct: boolean

Defined in: src/types/sparql.ts:393

Whether the query is a SELECT DISTINCT.


entailment: SparqlEntailmentRegime

Defined in: src/types/sparql.ts:385

Entailment regime the translation was performed under.


form: SparqlQueryForm

Defined in: src/types/sparql.ts:383

Query form: select / ask / construct / describe.


optional limit?: number

Defined in: src/types/sparql.ts:397

LIMIT, when the query carries one.


offset: number

Defined in: src/types/sparql.ts:399

OFFSET (0 when the query carries none).


orderBy: SparqlOrderByKey[]

Defined in: src/types/sparql.ts:395

ORDER BY keys, in order.


osfql: SparqlOsfqlLeaf[]

Defined in: src/types/sparql.ts:387

Every OSFQL leaf statement, in plan order.


plan: SparqlPlanNode

Defined in: src/types/sparql.ts:389

The algebra plan tree.


optional projection?: string[]

Defined in: src/types/sparql.ts:391

Projected variables (without the leading ?); undefined for SELECT *.