sparqldbpediafederated-queries

SPARQL federated query "SERVICE" returns Virtuoso RDFZZ Error: unexpected variable name 'stubvar14'


I want to get a list of Persons from two different SPARQL-Endpoints, so I'm using this query on de.dbpedia:

PREFIX category-en: <http://dbpedia.org/resource/Category:>
SELECT distinct *
WHERE {
?name dcterms:subject category-de:Haus_Liechtenstein.
?name rdf:type foaf:Person.
SERVICE <http://dbpedia.org/sparql> {
?name dcterms:subject category-en:Princely_Family_of_Liechtenstein.
?name rdf:type foaf:Person.
}
MINUS {?name dbpedia-owl:deathDate ?d}
}

I get then the following error:

Virtuoso RDFZZ Error DB.DBA.SPARQL_REXEC('http://dbpedia.org/sparql', ...) has received result with unexpected variable name 'stubvar14'

Any idea what I'm doing wrong? Thanks a lot!


Solution

  • So the problem is that although both these queries work fine separately, but the service part in the combined query is trying to filter the first set based on the second set. I think what you are missing is a union:

    PREFIX category-en: <http://dbpedia.org/resource/Category:>
    SELECT distinct count(?name)
    WHERE {
    {
        ?name dcterms:subject category-de:Haus_Liechtenstein.
        ?name rdf:type foaf:Person.
    }
    union{
        SERVICE silent <http://dbpedia.org/sparql>{
        ?name dcterms:subject category-en:Princely_Family_of_Liechtenstein.
        ?name rdf:type foaf:Person.
    }
    }
    MINUS {?name dbpedia-owl:deathDate ?d}
    }