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
852 stars 211 forks source link

SPARQL numeric functions break on non-numeric args #383

Open knoan opened 9 years ago

knoan commented 9 years ago

The following query fails with Virtuoso 22023 Error SR048: Function abs needs a numeric type as its argument, not an argument 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 ?a ?e (abs(?e) as ?v) {

  ?a a dbo:Automobile; dbp:engine ?e

} limit 100

The dbp:engine predicate contains both xsd:decimal values and IRI references and guarding against non-numeric values is neither straightforward nor efficient.

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

HughWilliams commented 9 years ago

This issue has been reported to development to look into ...