virtuoso-opensource icon indicating copy to clipboard operation
virtuoso-opensource copied to clipboard

Virtuoso 7.1.0 does not return correct datatype for language-specified strings

Open micheldumontier opened this issue 11 years ago • 7 comments

Using http://affymetrix.bio2rdf.org/sparql

SELECT ?datatype
WHERE {
 ?s a http://bio2rdf.org/affymetrix_vocabulary:Probeset .
 ?s http://purl.org/dc/terms/title ?o .  
  FILTER isLiteral(?o)
  BIND(DATATYPE(?o) AS ?datatype) .
}
limit 1

returns an empty value, but is expected to return rdf:langString as per http://www.w3.org/TR/sparql11-query/#func-datatype

LANG(?o) does return the language string.

micheldumontier avatar Jun 27 '14 14:06 micheldumontier

Hi Michel, LANG(?o) does return the language string, ex:

SELECT LANG(?o )
WHERE {
?s http://purl.org/dc/terms/title ?o .
BIND(DATATYPE(?o) AS ?datatype) .
}
limit 1

-- demo live results: -- http://bit.ly/1jUUQg9

Note that I've changed a bit your initial query as:

SELECT ?datatype
WHERE {
?s a http://bio2rdf.org/affymetrix_vocabulary/Probeset .
?s http://purl.org/dc/terms/title ?o .

FILTER isLiteral(?o)
BIND(DATATYPE(?o) AS ?datatype) .
}
limit 1

returns nothing. Even if I remove BIND, still no data (ditto FILTER isLiteral(?o)):

SELECT ?o
WHERE {
?s a http://bio2rdf.org/affymetrix_vocabulary/Probeset .
?s http://purl.org/dc/terms/title ?o .

FILTER isLiteral(?o)
}
limit 1

-- demo live results: -- http://bit.ly/1iN60st

But if I remove:

?s a http://bio2rdf.org/affymetrix_vocabulary/Probeset .

i.e., the query becomes:

SELECT ?datatype
WHERE {
?s http://purl.org/dc/terms/title ?o .

FILTER isLiteral(?o)
BIND(DATATYPE(?o) AS ?datatype) .
}
limit 1

then returns no data.

Now we can change it to:

SELECT DATATYPE(?o)
WHERE {
?s http://purl.org/dc/terms/title ?o .
}
limit 1

or even:

SELECT (iri(sql:RDF_DATATYPE_OF_OBJ(?o, 'untyped!'))) 
WHERE {
?s http://purl.org/dc/terms/title ?o .
}
limit 1

which also does not return any result.

I have notified development to take look into this.

Best Regards, Rumi Kocis

rumito avatar Jun 27 '14 14:06 rumito

Is this issue still unsolved? I'm currently experiencing an empty response to datatype() when applied to a string with a language tag like "test"@en

Virtuoso version 07.20.3233 on Linux (x86_64-pc-linux-gnu) Single Server Edition

rogargon avatar Nov 24 '22 22:11 rogargon

If you want the language tag for a string object value, using LANG(?o) directly in the select list should return it, i.e. —

select LANG(?o} where {?s ?p ?o} limit X

HughWilliams avatar Nov 27 '22 21:11 HughWilliams

No, the problem is not with the language tag. The issue is that we get an empty response to datatype() when applied to a language string. This differs from the behaviour of other SPARQL engines and breaks our semantic data explorer tool Rhizomer.

Rhizomer builds faceted views with differentiated ranges and this doesn't work for strings with a language tag because an empty response is received, which can not be used later for filtering results based on that facet.

rogargon avatar Nov 28 '22 08:11 rogargon

Do you have a sample test SPARQL query running against the Virtuoso hosted http://dbpedia.org/sparql endpoint that demonstrates the problem being encountered by your application, to enable the problem to be seen directly against the SPARQL endpoint ?

HughWilliams avatar Nov 28 '22 10:11 HughWilliams

For instance, just tried the following query using DBpedia SPARQL (version 08.03.3326):

SELECT ?langStr (datatype(?langStr) AS ?datatype)
WHERE { 
    BIND("test"@en AS ?langStr)
}

The result for ?datatype is empty, so it appears that version is experiencing the same issue.

With Fuseki (versions 4.3.2 and 4.6.1) I'm getting the expected result: <http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>.

With our Virtuoso deployment (version 07.20.3233), we are getting also an empty response, though, for that specific query, we are getting the following error:

Virtuoso 37000 Error SP031: SPARQL compiler: The list of return values contains '*' but the pattern does not contain variables

rogargon avatar Nov 28 '22 12:11 rogargon

Virtuoso supports SPARQL 1.1, which is based on the RDF 1.0 specs, where a literal cannot have both a lang and datatype; this is what Virtuoso currently supports. In RDF 1.1, literals are allowed to have both lang and datatype, which is what you appear to be seeking support for? Adding such support is not a simple process, as it would have side effects on the Virtuoso SPARQL/RDF ecosystem, and thus requires significant review and work to implement, which needs to be scheduled by development.

If a literal does not return a datatype, it should be safe to assume it is a lang type, which your application should be able to cater for to work with RDF 1.0-supporting SPARQL engines, and the lang() function used to obtain the lang tags if required.


The Virtuoso 37000 Error SP031: SPARQL compiler: The list of return values contains '*' but the pattern does not contain variables error with the Virtuoso 7 engine can be avoided by unticking the Strict checking of void variables checkbox option on the SPARQL endpoint form page ...

HughWilliams avatar Nov 28 '22 13:11 HughWilliams