Python language simple table function conversion
The code from the Python language scalar function can be reused as a simple table function by making minor modifications to the registration.
Code
The code is the same as found in the Python language scalar function section.
Deployment
Deploy the script by using the same steps as found in the Python language scalar function
section:
$NZ_EXPORT_DIR/ae/utilities/bin/compile_ae --language python64 \
--template deploy ./applyop.py --version 3
Registration
Register the executables by using the modified command, which changes
--template
, --return
and --sig
to be appropriate
for a table
function:$NZ_EXPORT_DIR/ae/utilities/bin/register_ae --language python64 --version 3 \
--template udtf --exe applyop.py \
--sig "applyop_table(varchar(1), int4, int4)" \
--return "table(result int4)"
Running
The AE can now be run in
SQL:
SELECT * FROM TABLE WITH FINAL(applyop_table('+', 4, 5));
RESULT
--------
9
(1 row)