stardogfederated-queries

Startdog Federated Query with variable service


my Stardog database contains service descriptions of SPARQL endpoints. I'm now trying to select a specific service and call it in the query, as described in https://www.w3.org/TR/2013/REC-sparql11-federated-query-20130321/#values

PREFIX  void: <http://rdfs.org/ns/void#>
PREFIX  dc:   <http://purl.org/dc/elements/1.1/>
PREFIX  doap: <http://usefulinc.com/ns/doap#> 

SELECT ?service ?projectName
WHERE {
  # Find the service with subject "remote".
  ?p dc:subject ?projectSubject ;
     void:sparqlEndpoint ?service .
     FILTER regex(?projectSubject, "remote")

  # Query that service projects.
  SERVICE ?service {
     ?project  doap:name ?projectName . } 
}

Unforunately, Stardog throws an exception, telling me that the variable is not an URI:

com.complexible.stardog.plan.eval.operator.OperatorException: Cannot execute a service query with a variable ref which binds to non-URI values

Casting the "?service" variable in a BIND statement with the IRI constructor and using the bound variable doesn't help either. How to ensure that the variable is an IRI, in order to get Stardog to execute the federated query?


Solution

  • Stardog, as of version 4.1, doesn’t support variables for the service URL (See the documentation). You can only have a variable in the service URL if you set the parameter value before execution, e.g. using --bind option in the CLI or the Query.parameter(String,Value) function in the API. So you'd need to first execute the query to retrieve service URLs the execute one query for each result.

    UPDATE: As of version 5.2 Stardog supports service variables so this query should work as-is.