SPARQL Federated Query

Hi @hwilliams,

Have you a real example of SPARQL Federated Query using SERVICE I can’t find and also even with my local data with DBPEDIA, this query for example not works:

    BASE <http://localhost:8890/TotRedDipcomune#>
    PREFIX iri: <http://localhost:8890/TotRedDipcomune#>
    PREFIX uri_comune: <http://localhost:8890/schemas/TotRedDipcomune/comune>
    PREFIX dbpedia: <http://dbpedia.org/resource/>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    
    SELECT * 
    FROM iri:
    WHERE {
      ?s uri_comune: ?localCity.
      
      OPTIONAL {
        SERVICE <http://dbpedia.org/sparql> {
          ?dbpediaCity rdfs:label ?cityLabel.
          FILTER (LANG(?cityLabel) = 'it' && ?localCity = ?dbpediaCity)
        }
      }
    }
    LIMIT 10

Result:

Because I think this must be the power of OpenData… :grinning:

The following post Exploiting the LOD Cloud Knowledge Graph using SPARQL-FED demonstrates a Federated SPARQL Query with the remote service clauses against the DBpedia and Wikidata SPARQL endpoints, with live link to see query execution.

1 Like

Hi @hwilliams,

during the query have a permission error:

      Virtuoso RDF02 Error SR619: SPARUL LOAD SERVICE DATA access denied: database user 107 (SPARQL) has no write permission on graph https://query.wikidata.org/sparql
      
      SPARQL query:
      define sql:big-data-const 0
      #output-format:text/html
      define sql:signal-void-variables 1
      PREFIX wd: <http://www.wikidata.org/entity/>
      PREFIX wdt: <http://www.wikidata.org/prop/direct/>
      PREFIX wdtn: <http://www.wikidata.org/prop/direct-normalized/>
      PREFIX dbo: <http://dbpedia.org/ontology/>
      PREFIX dct: <http://purl.org/dc/terms/>
      
      SELECT DISTINCT
          ?person 
          ?dbpediaURI 
          # ?dateOfBirth
          # ?countryName
          ?subject
          ?subjectLabel
      WHERE
        {
            SERVICE <https://query.wikidata.org/sparql>
                {
                    SELECT *
                    WHERE 
                        { 
                            ?person wdt:P106 wd:Q10833314 ;
                                        rdfs:label 'Nick Kyrgios'@en ;
                                        wdt:P569 ?dateOfBirth ;
                                        wdt:P27 [ rdfs:label ?countryName ] .
                            filter(lang(?countryName) = "en")
                        }
                }
      
        SERVICE <http://dbpedia.org/sparql>
                {
                    SELECT *
                    WHERE 
                        { 
                            ?dbpediaURI owl:sameAs ?person;
                            dct:subject ?subject.
                            ?subject rdfs:label ?subjectLabel
                        }
                }

Are you running the SPARQL-FED query on the same Virtuoso instance your original SPARQL-FED query in this topic was run on ?

Try running the following commands from isql:

DB.DBA.RDF_DEFAULT_USER_PERMS_SET ('SPARQL', 7);
grant select on "DB.DBA.SPARQL_SINV_2" to "SPARQL";
grant execute on "DB.DBA.SPARQL_SINV_IMP" to "SPARQL";

and then reattempt running the SPARQL-FED query.

Hi @hwilliams,

now my error is:

Virtuoso 22023 Error The service https://query.wikidata.org/sparql has no description and the site is not responding as a SPARQL endpoint

  SPARQL query:
  define sql:big-data-const 0
  #output-format:text/html
  define sql:signal-void-variables 1
  PREFIX wd: <http://www.wikidata.org/entity/>
  PREFIX wdt: <http://www.wikidata.org/prop/direct/>
  PREFIX wdtn: <http://www.wikidata.org/prop/direct-normalized/>
  PREFIX dbo: <http://dbpedia.org/ontology/>
  PREFIX dct: <http://purl.org/dc/terms/>
  
  SELECT DISTINCT
    ?person 
    ?dbpediaURI 
    # ?dateOfBirth
    # ?countryName
    ?subject
    ?subjectLabel
  WHERE
  {
      SERVICE <https://query.wikidata.org/sparql>
          {
              SELECT *
              WHERE 
                  { 
                      ?person wdt:P106 wd:Q10833314 ;
                                  rdfs:label 'Nick Kyrgios'@en ;
                                  wdt:P569 ?dateOfBirth ;
                                  wdt:P27 [ rdfs:label ?countryName ] .
                      filter(lang(?countryName) = "en")
                  }
          }
  
          SERVICE <http://dbpedia.org/sparql>
          {
              SELECT *
              WHERE 
                  { 
                      ?dbpediaURI owl:sameAs ?person;
                      dct:subject ?subject.
                      ?subject rdfs:label ?subjectLabel
                  }
          }
      
  }

Maybe the endpoint is not working anymore…

The SPARQL-FED query runs fine against our live URIBurner Link from the Exploiting the LOD Cloud Knowledge Graph using SPARQL-FED post and against my local Virtuoso instance. So I am not sure why it would not work for you.

The Virtuoso 22023 Error The service {sparql-endpoint-url} has no description and the site is not responding as a SPARQL endpoint errors occur if the remote URL passed in the service clause is invalid ie not a SPARQL endpoint or the site is down.
But the site is up and running from my testing thus I would suggest trying again.