Python language simulated row function
This example uses the following file name: timeSplit.py
Code
import nzae
class TimeSplitAe(nzae.Ae):
def _getFunctionResult(self, row):
return row[0].split(":")
TimeSplitAe.run()
Deployment
Deploy the script:
$NZ_EXPORT_DIR/ae/utilities/bin/compile_ae --language python64 \
--template deploy ./timeSplit.py --version 3Registration
Since there is no built-in concept of a row function in Netezza SQL—although there is one in the
Python adapter interface—this function is registered as a table function, even though it outputs
only one row per input
row:
$NZ_EXPORT_DIR/ae/utilities/bin/register_ae --language python64 --version 3 \
--template udtf --exe timeSplit.py --sig "time_split(varchar(20))" \
--return "table(hour varchar(2), minute varchar(2), second varchar(2))"Running
Run the query in nzsql:
SELECT * FROM TABLE WITH FINAL(time_split('13:22:47'));
HOUR | MINUTE | SECOND
------+--------+--------
13 | 22 | 47