SPARQL type conversion?

I have the following SPARQL query:

PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn#> PREFIX dtp: <http://dtp-126.sncs.abdn.ac.uk#> PREFIX dbp: <http://dbpedia.org/resource/> SELECT ?value ?time WHERE { dtp:CD7514 ssn:madeObservation ?observation . ?observation ssn:observedProperty ?property . ?property ssn:hasValue <http://dbpedia.org/resource/Temperature> . ?observation ssn:observationResult ?observationValue . ?observationValue ssn:hasValue ?value . ?observationValue ssn:observationSamplingTime ?time FILTER(?time > 1291908000) } 

Which, in a nutshell, selects all observations of the temperature sensor from the dtp sensor: CD7514 and filters values ​​smaller than the specified time stamp.

However, adding a filter constraint returns 0 results (when there are observations corresponding to this time region!)

Is it possible that? time is a varchar / text / String data type, and therefore the comparison cannot be performed? If so, is it possible to do the conversion in SPARQL?

+4
source share
2 answers

The solution to this was to simply add quotation marks around the timestamp.

+1
source

This will only work if the time value you use has the same number of digits, as it will strongly compare. Best fix:

 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> ... FILTER(xsd:integer(?time) > 1291908000) 

Will this run the value in? time for an integer, and then do a numerical comparison with it.

+14
source

Source: https://habr.com/ru/post/1332099/


All Articles