Perl language simulated row function
This example uses the following file name: TimeSplit.pm
Code
package TimeSplit;
use nzae::Ae;
use strict;
use autodie;
our @ISA = qw(nzae::Ae);
my $ae = TimeSplit->new();
$ae->run();
sub _getFunctionResult(@)
{
my $self = shift;
my @currentTime = @_;
my @time = split(/:/, $currentTime[0]);
return (@time);
}
1;
Deployment
Deploy the
script:
$NZ_EXPORT_DIR/ae/utilities/bin/compile_ae --language perl --version 3 \
--template deploy TimeSplit.pmRegistration
Since there is no built-in concept of a row function in Netezza SQL—although there is one in the
Perl 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 perl --version 3 \
--template udtf --exe TimeSplit.pm --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