openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
https://vos.openlinksw.com
Other
864 stars 210 forks source link

SPARQL with VALUES clause after WHERE does not work (generated from a SERVICE clause) #921

Open tfrancart opened 4 years ago

tfrancart commented 4 years ago

See answer to SERVICE against Virtuoso DBPedia Gives “Virtuoso S0022 Error SQ200 : No Column” on StackOveflow.

I run a SPARQL query in a local GraphDB triplestore that contains a SERVICE clause that goes to DBPedia Virtuoso. The query basically fetches labels of some DBPedia URIs directly from DBPedia (note the subquery executes first to fetch local results, before passing in these results to the SERVICE clause):

SELECT DISTINCT ?uri (STR(?theLabel) AS ?label)
WHERE {
 {
  SELECT DISTINCT ?uri 
  WHERE {
    ?domain a <http://xmlns.com/foaf/0.1/Person> .
    ?domain <http://virtual-assembly.org/pair#hasKeyword> ?uri .
  }
  }

  SERVICE <http://dbpedia.org/sparql> {
    ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?theLabel .
    FILTER(lang(?theLabel) = 'fr')
  }

}
ORDER BY ?label

I get the following error from Virtuoso while evaluating the service clause Virtuoso S0022 Error SQ200 :

Query evaluation error: org.eclipse.rdf4j.query.QueryEvaluationException: Virtuoso S0022 Error SQ200: No column uri.

SPARQL query:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#> 

SELECT  ?theLabel ?__rowIdx WHERE {
 ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?theLabel .
 FILTER(lang(?theLabel) = 'fr')
} 
VALUES (?__rowIdx ?uri) {  ("0" <http://dbpedia.org/resource/Semantic_Web> ) ("1" <http://dbpedia.org/resource/Peer-to-peer> ) ("2" <http://dbpedia.org/resource/Collaboration> ) ("3" <http://dbpedia.org/resource/Free_software> ) ("4" <http://dbpedia.org/resource/Social_transformation> ) ("5" <http://dbpedia.org/resource/Social_network> ) ("6" <http://dbpedia.org/resource/Ecology> ) ("7" <http://dbpedia.org/resource/Activism> ) ("8" <http://dbpedia.org/resource/Supernatural> ) ("9" <http://dbpedia.org/resource/Sociology> ) ("10" <http://dbpedia.org/resource/Natural_science> ) ("11" <http://dbpedia.org/resource/Popular_science> ) ("12" <http://dbpedia.org/resource/Cooperation> ) ("13" <http://dbpedia.org/resource/Wikimedia_Commons> ) ("14" <http://dbpedia.org/resource/Musician> ) } 

(HTTP status 500)

The query received by Virtuoso is valid SPARQL, with a VALUES clause after the WHERE clause. As mentioned in the StackOverflow question, putting the VALUES clause inside the WHERE would work, but I don't have my hand on how GraphDB generates that SPARQL.

This is blocking any attempt to have federated query from GraphDB to Virtuoso.

HughWilliams commented 4 years ago

This issue has already been reported to development to look into and fix based on the StackOverflow discussion comments from Kingsley ...