SPARQL 1.1 and Openlink Virtuoso: First steps with federated queries

Learning Sparql
Learning Sparql

Last week I stared reading “Learning SPARQL” by Bob DuCharme (O’Reilly) and I’m very happy with it. The book is very didactic and explain every SPARQL aspect with the help of useful practical examples.

The tool I decided to use SPARQL with was the OpenLink’s Virtuoso Open Source edition. Although I’ve created an Amazon Linux machine and installed a Virtuoso instance in it from souce code, I decided to install Virtuoso on Windows XP laptop. The reason was simple. I’d like to be able to use Virtuoso while in Saquarema (The “Maracanã” of surf in Rio de Janeiro) where I prefer not to have an internet connection.

By the way, when following the above link to install Virtuoso on Windows, the Windows service created to manage Virtuoso‘s startup seems not to work properly. As for this post my intention is to talk about SPARQL I’ll let to talk about such problem on a next post.

Back to SPARQL in Virtuoso, one interesting capability that really made me happy was the possibility to SELECT remote SPARQL endpoints when connected to my local SPARQL endpoint. For exemple, I connect to my local Virtuoso and SELECT DBpedia’s SPARQL endpoint. That’s  called Federated Query.

This is made possible by using the SERVICE keyword that is new on SPARQL 1.1. Thanks to Openlink by making SPARQL 1.1 possible on VIRTUOSO 🙂

The following is an example of such SPARQL 1.1 query:

SELECT ?p ?o
 { SELECT ?p ?o
 WHERE { < > ?p ?o . }

Before issuing this query I just had to remember that Virtuoso isql‘s interface (either command line of on Conductor) cannot be used to issue SPARQL commands. The isql interface, as its name stands for, is a SQL client and not a SPARQL client. Therefore, in order to issue SPARQL queries I had to log in at the Conductor interface (http://localhost:8890/conductor/) and the go to “Linked Data -> Sparql“.

When trying to execute the SPARQL query above, you’ll see an error message complaining about permission somewhere in Virtuoso’s database. You’ll have to issue two SQL GRANT commands in isql interface. Here they are:

grant select on "DB.DBA.SPARQL_SINV_2" to “SPARQL”;
grant execute on "DB.DBA.SPARQL_SINV_IMP" to "SPARQL";

After these two GRANTs you’ll be able to sucessfully execute a federated query in your Virtuoso installation. Here is a small of of the result of my SPARQL SELECT above about Saquarema.

Result of a "Saquarema" SPARQL query against DBpedia endpoint
Result of a “Saquarema” SPARQL query against DBpedia endpoint

That makes Linked Data really possible. I’ll explore and talk more about it later.

See you… bye!


2 comentários sobre “SPARQL 1.1 and Openlink Virtuoso: First steps with federated queries

  1. Thank you for this information 🙂
    One correction: You have non-standard quote characters in the following line:
    grant select on “DB.DBA.SPARQL_SINV_2” to “SPARQL”;

    This results in the error:
    *** Error 42000: [Virtuoso Driver][Virtuoso Server]SR137: Bad user name in GRANT/REVOKE

    Please change this to:
    grant select on “DB.DBA.SPARQL_SINV_2” to “SPARQL”;

    I spend quite a long time searching for this error having cut and paste these lines!

Deixe uma resposta

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do

Você está comentando utilizando sua conta Sair / Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair / Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair / Alterar )

Foto do Google+

Você está comentando utilizando sua conta Google+. Sair / Alterar )

Conectando a %s