I was surprised to run this query
SELECT ?s, datatype(?s), ?p, datatype(?p), ?o, datatype(?o)
WHERE {
?s ?p ?o .
}
LIMIT 100
and discover that the datatype(?o) column is blank.
The first row of the result shows this:
?s http://dbpedia.org/ontology/deathDate
datatype(?s) http://www.w3.org/2001/XMLSchema#anyURI
?p http://www.w3.org/1999/02/22-rdf-syntax-ns#type
datatype(?p) http://www.w3.org/2001/XMLSchema#anyURI
?o http://www.w3.org/2002/07/owl#FunctionalProperty
datatype(?o)
The definition of the datatype function in the SPARQL 1.1 spec doesn't shed any light into why datatype(?o) would be empty. I don't know whether this is expected behavior or whether it's a Virtuoso quirk.
datatype(?s)evaluates to an error.datatypetakes a literal for an argument but?pand?scan't be literals and?oisn't in the data shown.As error in a assignment (BIND, or here project expression) leaves it unbound.
With legal SPARQL syntax:
SELECT (datatype(<http//example/>) AS ?dts ) {}evaluates to