title: SERVICE against Virtuoso DBPedia Gives "Virtuoso S0022 Error SQ200 : No Column"
body: <p>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 executed first to fetch local results, before passing in these results to the SERVICE clause) :</p>
  
  <pre><code>SELECT DISTINCT ?uri (STR(?theLabel) AS ?label)
  WHERE {
   {
    SELECT DISTINCT ?uri 
    WHERE {
      ?domain a &lt;http://xmlns.com/foaf/0.1/Person&gt; .
      ?domain &lt;http://virtual-assembly.org/pair#hasKeyword&gt; ?uri .
    }
    }
  
    SERVICE &lt;http://dbpedia.org/sparql&gt; {
      ?uri &lt;http://www.w3.org/2000/01/rdf-schema#label&gt; ?theLabel .
      FILTER(lang(?theLabel) = 'fr')
    }
  
  }
  ORDER BY ?label
  </code></pre>
  
  <p>I get the following error from Virtuoso while evaluating the service clause <strong>Virtuoso S0022 Error SQ200</strong> :</p>
  
  <pre><code>Query evaluation error: org.eclipse.rdf4j.query.QueryEvaluationException: Virtuoso S0022 Error SQ200: No column uri.
  
  SPARQL query:
  PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
  PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
  PREFIX sesame: &lt;http://www.openrdf.org/schema/sesame#&gt;
  PREFIX owl: &lt;http://www.w3.org/2002/07/owl#&gt;
  PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
  PREFIX fn: &lt;http://www.w3.org/2005/xpath-functions#&gt; 
  
  SELECT  ?theLabel ?__rowIdx WHERE {
   ?uri &lt;http://www.w3.org/2000/01/rdf-schema#label&gt; ?theLabel .
   FILTER(lang(?theLabel) = 'fr')
  } 
  VALUES (?__rowIdx ?uri) {  ("0" &lt;http://dbpedia.org/resource/Semantic_Web&gt; ) ("1" &lt;http://dbpedia.org/resource/Peer-to-peer&gt; ) ("2" &lt;http://dbpedia.org/resource/Collaboration&gt; ) ("3" &lt;http://dbpedia.org/resource/Free_software&gt; ) ("4" &lt;http://dbpedia.org/resource/Social_transformation&gt; ) ("5" &lt;http://dbpedia.org/resource/Social_network&gt; ) ("6" &lt;http://dbpedia.org/resource/Ecology&gt; ) ("7" &lt;http://dbpedia.org/resource/Activism&gt; ) ("8" &lt;http://dbpedia.org/resource/Supernatural&gt; ) ("9" &lt;http://dbpedia.org/resource/Sociology&gt; ) ("10" &lt;http://dbpedia.org/resource/Natural_science&gt; ) ("11" &lt;http://dbpedia.org/resource/Popular_science&gt; ) ("12" &lt;http://dbpedia.org/resource/Cooperation&gt; ) ("13" &lt;http://dbpedia.org/resource/Wikimedia_Commons&gt; ) ("14" &lt;http://dbpedia.org/resource/Musician&gt; ) } 
  
  (HTTP status 500)
  </code></pre>
  
  <p>The SPARQL query sent to Virtuoso is valid to my eyes.</p>
  
  <p>Of course I don't have my hand on how GraphDB generates the query, but is there any way I can rewrite the original query to work around this ?</p>
  
  <p>Thanks</p>