How can I create a custom function in apache-age,
similar to the function we can create using PostgreSQL statement;
CREATE FUNCTION f2(INTEGER) returns INTEGER AS 'SELECT $1' LANGUAGE SQL;
I need to create a function just like the above function created in Postgresql. Input of function should be integer and output should also be integer.
2
Answers
In Apache-AGE you can create the custom function in same way as in PostgreSQL.
For this you need to use "CREATE FUNCTION" clause. A simple example of function which accepts INTEGER and returns INTEGER is as:
This function is accepting INTERGER and is returning its square.
All of your function calculation goes after "SELECT" statement. For Example, if you want to subtract i after finding its square then you will modify it as:
Basically, there are two methods to create custom function in Apache AGE. One is using python or using SQL. For simple functions, SQL method will be used and for complex functions python method will be used.
SQL method:
Function calling:
Python method: