Skip to content

Feature: Support default prefixes in SPARQL queries #647

@Laschoking

Description

@Laschoking

Currently each SPARQL query is required to contain all prefixes that are used within the query. While, for example, wikidata accepts a list of common prefixes, oxigraph will fail during the validation process if prefixes are missing.

Writing several queries in one program that possibly share a big number of prefixes can therefore feel bulky and inconvenient for users.

According to oxigraph/oxigraph#1177, oxigraph is planning to accept a collection of default prefixes when calling Query::Parse().

Yesterday, we discussed two non-exclusive options:

  1. Introduce a new import parameter for sparql e.g., default_prefixes={xsd, wikidata, ... } . This would result in pushing a list of hard coded prefixes into the query before the oxigraph validation.
    %% Note: In the validation process oxigraph will make all IRIs absolute and drop all prefixes. If the same prefix name is supplied several times in the query, that latest one will be used during validation and expansion of IRIs.

  2. Push the outer prefixes from the Nemo program into the query, for example

@prefix wd: <http://www.wikidata.org/entity/>.
@import test :- sparql{endpoint=<https://query.wikidata.org/sparql>, query= """SELECT * WHERE {?a ?b wd:Q123}""" }.

In my opinion option 1 is low effort but seems a little hacky. Once oxigraph allows a list of default prefixes, we can also remove the manual pushing of hard coded prefixes into the query and just pass them to the oxigraph parser directly.

Option 2 is nice to have and would especially come in handy when using custom prefixes.
Since I don't have much knowledge of the prefix expansion in the nemo parser I am not sure how much effort this will take.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestsparqlSPARQL query support
No fields configured for Feature.

Projects

Status
Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions