Thank you Mark, that worked.
And thanks for the tip. Does this approach have an overhead compared to my original code, especially if the function definition is not going to change (of course once things are fully developed) ? What I mean to ask is does the database keep track of the timestamp of the file to skip reading it repeatedly ?
Also, I foresee having a lot of related python functions, so ideally, I would prefer to keep the related functions together in a single file (like a module) and be able to refer to them by their name in the create function explicitly.
i.e., something like this.
CREATE FUNCTION test() RETURNS TABLE(i INTEGER) LANGUAGE PYTHON ‘/home/user/file.py:test_function’;
As, the way it is now, the file.py should contain a return statement outside of the body of a function.
i.e something like this.
return 101
This makes it impossible to test some of these things outside of the database using Python as
python3 file.py
will throw an error.
But on the other hand, if the above mentioned syntax is supported, we can write.
# file.py
def test_function():
return 101
if __name__ == '__main__':
test_function()
And this would work in both the database as well as outside of it. (not to mention we can have multiple functions in file.py (like a module )
But thanks for the work on integrating python into the database, the potential is quite immense given the emerging trends.
Joseph