Adding custom SPARQL query functions #592
hannahbast
started this conversation in
Show and tell
Replies: 2 comments 2 replies
-
|
@AndreaWesterinen Above is an example of how a custom query function can be added to QLever. Johannes (@joka921) implemented the foundation for this three months ago. We are thinking about how this can be simplified further, so that the necessary changes for adding a single function have to be made in only one place. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
This is "just" for functions, right? Like using it in FILTER, BIND or projection? Is there also some kind of feature for custom "magic predicates"? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here is an example how to add a custom SPARQL question function to the QLever codecase. The function squares the given number and can be invoked by an expression like SQR(?x) in a SPARQL query.
Rebuild the automatically generated ANTLR code using the instructions in https://github.com/ad-freiburg/qlever/blob/master/src/parser/sparqlParser/generated/README.md (in a nutshell: run the ANTLR jar in the respective directory).
In https://github.com/ad-freiburg/qlever/blob/master/src/parser/sparqlParser/SparqlQleverVisitor.h, add the following else-if to antlrcpp::Any visitBuiltInCall . This will link the SQR in the SPARQL query to an invocation of the function sparqlExpression::SquareExpression implemented in Step 1.
Beta Was this translation helpful? Give feedback.
All reactions