Open rvesse opened 5 years ago
How would you select the function to run if not via if()
? VALUES
or determining the function IRI by pattern matching in data describing the functions? In other words, it would help me to understand the issue if there were examples of using the dynamic function invocation.
In TopQuadrant we have used the call
function as provided by ARQ to check lexical forms against a datatype in a generic way:
BIND (call(?datatypeIRI, ?lexicalForm) AS ?literal)
If bound(?literal)
returns true
, then the lexical form is valid for that datatype. This makes use of the fact that datatype constructor functions return an error for invalid lexical forms. Only works for supported datatypes, of course.
This sounds similar to what was proposed by Maurizio Atzori in "Toward the Web of Functions: Interoperable Higher-Order Functions in SPARQL" It outlined more than what is being discussed here but it included something like a CALL() function
These are related:
Why?
Currently SPARQL has a fairly robust extension function mechanism that allows for arbitrary functions to be referred to by URIs. This allows for vendors to implement useful extensions and for those to be even interoperable if vendors publish definitions of the semantics of their functions, since then other vendors can also add implementations associated with the same URI.
However there is no way currently to do dynamic function invocation i.e. cases where you want to run different functions based on some conditions. The best you can do currently is to use
IF
to select different functions, which are known in advance, to evaluate based on some conditions e.g.This doesn't cover the use case of data driven function selection e.g. where the data itself encodes the desired function. So the following is currently illegal:
Existing Solutions
Apache Jena currently supports dynamic function invocation by introducing a new built-in function called
CALL()
in it's ARQ syntax:This is a n-ary function i.e. it can take any number of arguments. It's semantics are defined as follows: