openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
https://vos.openlinksw.com
Other
863 stars 210 forks source link

SPARQL temporal functions break on non-temporal args #384

Open knoan opened 9 years ago

knoan commented 9 years ago

The following query fails with Virtuoso 22007 Error DT001: Function year needs a datetime, date or time as argument 1, not an arg of type IRI_ID (243) on the http://dbpedia.org/sparql endpoint (Virtuoso 7.20).

prefix dbo: <http://dbpedia.org/ontology/>
prefix dbp: <http://dbpedia.org/property/>

select ?p ?d (year(?d) as ?y){

   ?ap a dbo:Person; dbp:birthDate ?d

} limit 100

The dbp:birthDate predicate contains both xsd:date values and IRI references and guarding against non-temporal values is neither straightforward nor efficient.

Same behaviour for all temporal functions (SPARQL 1.1 Query Language § 17.4.5), which would be expected to raise an error, i.e. to return an unbound value, if the argument is not a temporal value.

HughWilliams commented 9 years ago

This issue has been recreated and reported to development ...

Note the ?p variable in the result set of the query should be ?ap ...

cmarat commented 8 years ago

@HughWilliams any updates on this issue?

It is rather common, as unbound variables inside OPTIONAL{} and COALESCE() also cause DT001: Function year needs a datetime, date or time as argument 1, not an arg of type DB_NULL (204).

HughWilliams commented 8 years ago

@cmarat: No there is no fix for this issue yet ... I have added your request to the development bug report to raise priority level ...