virtuoso-opensource
virtuoso-opensource copied to clipboard
Extension function specification (SPARQL 1.1) not respected
Problem description
The SPARQL 1.1 extensions functions states that additional functions are accepted in queries defined under IRIs: A PrimaryExpression grammar rule can be a call to an extension function _named by an IRI_
bif:contains is actually no valid IRI (assuming no prefix was defined), so the usage of the prefix should be mandatory (or at least accepted, since so it is stated in the Spec), but Virtuoso does not accept it.
Problem reproduction
Virtuoso v7.2.0.1 was used. Following preparation (in isql)
SPARQL
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
INSERT DATA {GRAPH <urn:g> {<urn:s> rdfs:label "example label"}};
DB.DBA.VT_INC_INDEX_DB_DBA_RDF_OBJ ();
Once the data is inserted this query succeeds (as expected due to the custom support by Virtuoso)
SPARQL
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?o WHERE {<urn:s> rdfs:label ?o . FILTER(bif:contains(?o, "example"))}
However, this query fails even if it fits the spec and the used namespace is correct (meaning that the resulting IRI leads to the expected function):
SPARQL
PREFIX bif: <http://www.openlinksw.com/schema/sparql/extensions#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select distinct ?o where {<urn:s> rdfs:label ?o . FILTER(bif:contains(?o, "example"))}
leading to this error
SQLState: 37000
Message: SQ074: Line 4: SP030: SPARQL compiler, line 2: Prefixes 'sql:' and 'bif:' are reserved for SQL names at '<http://www.openlinksw.com/schema/sparql/extensions#>' before 'PREFIX'
SPARQL
PREFIX bif: <http://www.openlinksw.com/schema/sparql/extensions#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select distinct ?o where {<urn:s> rdfs:label ?o . FILTER(bif:contains(?o, "example"))}
Proposed solution
In order to be SPARQL 1.1 compliant, the prefix PREFIX bif: <http://www.openlinksw.com/schema/sparql/extensions#> should be allowed.
Furthermore, Virtuoso should not only react to the specific bif:contains string, but also to the whole function IRI (http://www.openlinksw.com/schema/sparql/extensions#contains), since query parsing engines might decide to delete prefixes. This last point sounds useless, but such a query would have the same semantics, so it should be processed in the same way by the SPARQL engine (in this case Virtuoso)
If the value of the prefix is not the expected one, throwing the mentioned error would be acceptable (reserving prefixes is not foreseen, since the real information is the complete IRI, but it is a minor compromise).
It should be noted that if bif is considered a scheme, bif:contains is in fact a valid IRI according to the RFC http://tools.ietf.org/html/rfc3987#section-2.1
@nvdk : true, but only if written like this <bif:contains> , otherwise according to the SPARQL syntax bif:contains is only a valid IRI if the prefix bif: is defined
Any updates @openlink ?
+1 -- is this a won't fix issue ?
@c-martinez,
The issue has been solved. Thus, simply lookup: http://www.openlinksw.com/schema/sparql/extensions#
Ah, perfect! Many thanks!
From: Kingsley Idehen [email protected] Sent: 03 November 2017 20:13:25 To: openlink/virtuoso-opensource Cc: Carlos Martinez Ortiz; Mention Subject: Re: [openlink/virtuoso-opensource] Extension function specification (SPARQL 1.1) not respected (#420)
@c-martinezhttps://github.com/c-martinez,
The issue has been solved. Thus, simply lookup: http://www.openlinksw.com/schema/sparql/extensions#
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/openlink/virtuoso-opensource/issues/420#issuecomment-341800225, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHa_V6omLOCJuB-hrzkr5ZkZ5QqlcPOiks5sy2XUgaJpZM4E81Ht.
We are trying to enable full-text search through Virtuoso in our RDF exploration tool Rhizomer. Our idea is to use bif:contains but we are blocked because we send the SPARQL query programmatically through Jena and it fails if the bif prefix is not defined.
If we define the prefix using the URI pointed out by @kidehen, like:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bif: <http://www.openlinksw.com/schema/sparql/extensions#>
SELECT (COUNT(DISTINCT ?instance) AS ?n)
FROM <http://dbpedia.org>
WHERE
{
?instance a ?class ; ?property ?value . FILTER(bif:contains(?value, "'linked data'"))
}
We get the following error:
Virtuoso 37000 Error SP030: SPARQL compiler, line 7: Prefixes 'sql:' and 'bif:' are reserved for SQL names at '<http://www.openlinksw.com/schema/sparql/extensions#>' before 'SELECT'
SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bif: <http://www.openlinksw.com/schema/sparql/extensions#>
SELECT (COUNT(DISTINCT ?instance) AS ?n)
FROM <http://dbpedia.org>
WHERE
{
?instance a ?class ; ?property ?value . FILTER(bif:contains(?value, "'linked data'")) }
}
The query works if we omit the bif prefix, but then we cannot use it through Rhizomer because it fails due to the undefined prefix. Consequently, we are currently blocked and unable to add the full text search feature to Rhizomer when the data is stored in Virtuoso.
@rogargon
You should use PREFIX bif: <http://www.openlinksw.com/schemas/bif#> instead.
HTH