Enabling SPARQL 1.1 Federated Query Processing in Virtuoso

Enabling SPARQL 1.1 Federated Query Processing in Virtuoso

Why

SPARQL 1.1 Federated Query (sometimes referred to by the original name, SPARQL-FED) processing permits Virtuoso to run SPARQL sub-queries (typically written using the SPARQL SERVICE clause) to be run against remote SPARQL endpoints, as described in the standard.

What

Enabling SPARQL 1.1 Federated Query processing in Virtuoso is just a question of granting a role or two to the SPARQL user.

The SPARQL_SELECT_FED role is mandatory.

The second SPARQL_LOAD_SERVICE_DATA role is optional, and is used for “introspecting” endpoints — those which store the data acquired from external sources while processing SPARQL queries, Federated and otherwise.

Note: the SPARQL_SPONGE role, which is automatically granted to the SPARQL user when the Sponger Cartridges VAD is installed, also enables SPARQL 1.1 Federated Query processing.

How

Federated SPARQL Query processing may be enabled in Virtuoso through use of either the Virtuoso Conductor (HTTP-based administration interface) or SQL commands.

Via the Virtuoso Conductor

  1. In the Virtuoso Conductor’s System Admin → User Account tab, locate the SPARQL user account, and click the Edit button on the right:

  2. Locate the Available list in the Account Roles section, select SPARQL_SELECT_FED, and optionally for “introspecting” endpoints (those which store data acquired from external sources while processing locally submitted queries) SPARQL_LOAD_SERVICE_DATA, and click the >> button to add them to the Selected list:

  3. With the necessary roles now in the Selected list, click the Save button to persist the settings for the SPARQL user:

  4. SPARQL 1.1 Federated Query processing is now enabled and ready for use.

Via SQL commands

The two commands below can be executed through any Virtuoso SQL interface (isql, ODBC, JDBC, etc.) while logged in as a user with sufficient permissions (typically dba or a user with DBA permissions).

The first command grants the required SPARQL_SELECT_FED role, and the second command grants the optional SPARQL_LOAD_SERVICE_DATA role for “introspecting” endpoints (those which store data acquired from external sources while processing locally submitted queries), each to the SPARQL user.

GRANT "SPARQL_SELECT_FED" TO "SPARQL";

GRANT "SPARQL_LOAD_SERVICE_DATA" TO "SPARQL"; -- optional

Finally run the following command as the dba user to discover the capabilities of the remote SPARQL endpoint:

SPARQL LOAD SERVICE <sparql-endpoint-iri> DATA 

Upon execution of the above command(s), SPARQL 1.1 Federated Query processing is enabled and ready for use.

Related: