ad-freiburg / qlever

Very fast SPARQL Engine, which can handle very large knowledge graphs like the complete Wikidata, offers context-sensitive autocompletion for SPARQL queries, and allows combination with text search. It's faster than engines like Blazegraph or Virtuoso, especially for queries involving large result sets.
Apache License 2.0
376 stars 45 forks source link

`RAND` operator should produce a `xsd:double` #1516

Closed romaintailhurat closed 7 hours ago

romaintailhurat commented 2 days ago

According to the SPARQL 1.1 spec, the RAND operator should produce a xsd:double between 0 and 1.

But it's not what I'm getting from the API. For example, with a query like:

PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?disorder ?random ?label where {
    ?disorder dc:type "disorder" .
    ?disorder rdfs:label ?label
    FILTER langMatches(lang(?label), "fr")
    BIND(RAND() as ?random)
} order by ?random limit 1000

I'm getting this kind of payload:

{
  "disorder": {
    "type": "uri",
    "value": "http://snomed.info/id/4448006"
  },
  "label": {
    "type": "literal",
    "value": "céphalée allergique",
    "xml:lang": "fr"
  },
  "random": {
    "datatype": "http://www.w3.org/2001/XMLSchema#int",
    "type": "literal",
    "value": "-576459726194747256"
  }
}

The type of the random variable being xsd:int instead of xsd:double and the value is way out of the spec bounds.

hannahbast commented 8 hours ago

@romaintailhurat Thanks for pointing this out to us + a PR is already under way. Did this just occur to you or is the range and datatype important for you application?

romaintailhurat commented 7 hours ago

Nothing important for my current use case, i was just testing this operator on two endpoints: a qlever instance and a GraphDB one, i noticed this subtle difference.

romaintailhurat commented 7 hours ago

And thank you for the quick fix!