first time post here. I was hoping someone could help me make custom SPARQL functions for use within the Jena (ARQ) API. I need SPARQL to do some aggregation, and I know that it already implements avg, count, min, max, and sum, but I need to be able to do standard deviation and median as well (I also need range, but that can be done with using just min and max).
I was hoping the query could be similar to what you use for the already implemented functions:
PREFIX example: <http://www.examples.com/functions#>
PREFIX core: <http://www.core.com/values#>
SELECT (stddev(?price) as ?stddev)
WHERE {
?s core:hasPrice ?price
}
I don’t know if that is possible or not, but if I need to use it like other custom functions that would be fine too, as long as it still gets the standard deviation of the results.
All I know is that the functions would be written in Java, which I already know pretty well. So, I was wondering if anyone knew of a good way to go about this or where to start looking for some guidance. I’ve tried looking for documentation on it, but there doesn’t seem to be anything. Any help would be greatly appreciated.
Thanks in advance.
I am not sure you can do what you want without actually changing the grammar.
SUM(…) for example is a keyword defined by the SPARQL grammar:
A filter function or a property function is probably not what you are looking for.
By the way, you do not get STDDEV in SQL as well. Is it because two passes over the data are necessary?