C++ language simple table function conversion
The code from the C++ 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 C++ language scalar function section.
Compilation
Compilation is the same as the one performed in local or remote
modes.
$NZ_EXPORT_DIR/ae/utilities/bin/compile_ae --language cpp --template compile \
--exe applyopcpp --compargs "-g -Wall" --linkargs "-g" applyopcpp.cpp \
--version 3Registration
Register the executables by using the modified command, which changes
--template
and --return to be appropriate for a table
function:$NZ_EXPORT_DIR/ae/utilities/bin/register_ae \
--sig "tapplyop_cpp(VARARGS)" \
--return "table(d double)" --language cpp --template udtf \
--exe applyopcpp --version 3Running
The AE can now be run in SQL:
SELECT * FROM TABLE WITH FINAL(tapplyop_cpp('+',1,2));
D
---
3
(1 row)
SELECT * FROM TABLE WITH FINAL(tapplyop_cpp('+',1,2,3,4));
D
---
10
(1 row)