Functions
By default the gitql-std
component contains the standard functions and aggregations functions inspired by
SQLite, MySQL, PostgreSQL, MSSQL ...etc.
This can be more than enough in most cases, but maybe you want to create a special functions related to your data, or your custom type.
Creating a custom function
To create a new function you need to provide a name, signature (What are parameters types and return type) and the actual function implementation, the SDK expects a Map with type HashMap<&'static str, Signature>
to map function name to the signature, and another map of type &'static HashMap<&'static str, Function>
to map function name to the actual implementation.
By default you can got those two maps with all standard functions like this
You can remove, replace or insert in those maps, lets take an example of adding new function
Lets start by the function implementation, it should take an Array of Values as arguments, and return Value, so our function will take two parameters, file path and extension, and return true if this path end with this extension
After implementing our new function let append it to our clone of the standard functions
NOTE: You can remove functions, or even create a new empty map with only your functions.
NOTE: The same concepts works with Aggregations functions.
NOTE: Later you will see how to create function with your own types.