Closed kad-beekw closed 3 years ago
I am surprised that conversion from xsd:gYear to xsd:double is not supported given that a year is an integer, which is a double. It is supported on Fuseki endpoints for instance.
The implicit conversion is necessary because it is common to have numeric values represented (wrongly) as simple literals. The simplest solution will probably to offer the lexical comparison operators (after, before, from.. to ..), which corresponds to your Solution 2.
Finally, I found a simpler and more generic version of your Possible solution 1.
xsd:double(str(?thing))
to convert ?thing
to a number, whatever the datatype.
Note that the comparison filters are only available when there are literals that can be parsed as numbers.
Here is a query on your endpoint showing the fix : permalink
Observed
When a dataset contains
xsd:gYear
values, the current filtering approach in Sparklis does not work. When we try to filter for buildings between 1900 and 1910, Sparklis uses the following filter:^ Unfortunately, this filter is not allowed in SPARQL 1.1, because date/time (including year) values are not allowed to be cast to doubles.
Expected
Filters over values with datatype IRI
xsd:gYear
to work in SparklisPossible solutions
Possible solution 1
The following does work in SPARQL 1.1:
^ Notice that we need to do the following:
xsd:gYear
values toxsd:dateTime
. It is not clear from the SPARQL standard whether this is required, but the endpoints that we use seem to require this. (The SPARQL standard only explicitly mentions the case forxsd:dateTime
.)xsd:dateTime
we are allowed to extract the year component as an integer, using theyear()
function in SPARQL 1.1.Possible solution 2
According to the SPARQL 1.1 standard, the following filter should also work. However, this does not seem to be supported by all endpoint. I tested this with Virtuoso where this did not work, and tested this with Jena where this did work.