Java language integrated example
This section contains a series of related examples tying a number of techniques together.
Note: Compilation and registration examples that specify the --db option assume that there is
a valid database called "dev" on the Netezza appliance.
Concepts
Concepts covered in this section include:
- Combining different source files together to create more complex AE applications and facilitate code reuse.
- Using Java JAR files.
- Calling the same AE from different SQL Functions and choosing different logic paths based on environment variables.
- Execution time streaming of output from one AE into another.
- Table functions that return:
- exactly one output row after reading all input rows
- one output row per input row
- multiple output rows per input row
- Demonstration of the lower level AE connection API compared to using NzaeApiGenerator.
Test Data
This table data is used for all the examples in this section.
/* edutestdata.sql */
DROP TABLE edutestdata;
CREATE TABLE edutestdata (
distribution_key int4,
f1 int4,
f2 int8,
f3 double,
f4 numeric(10,3),
color varchar(32)
) distribute ON (distribution_key);
INSERT INTO edutestdata VALUES(1, 1, 2, 3.0, 4.0, 'red');
INSERT INTO edutestdata VALUES(2, 100, 300, 0.5, 0.5, 'red');
INSERT INTO edutestdata VALUES(3, -100, 300, 0.5, 0.5, 'red');
INSERT INTO edutestdata VALUES(4, 100, -300, 0.5, 0.5, 'red');
INSERT INTO edutestdata VALUES(1, 1, 2, 3.0, 4.0, 'green');
INSERT INTO edutestdata VALUES(2, 100, 300, 0.5, 0.5, 'green');
INSERT INTO edutestdata VALUES(3, -100, 300, 0.5, 0.5, 'green');
INSERT INTO edutestdata VALUES(4, 100, -300, 0.5, 0.5, 'green');
INSERT INTO edutestdata VALUES(1, 1, 2, 3.0, 4.0, 'blue');
INSERT INTO edutestdata VALUES(2, 100, 300, 0.5, 0.5, 'blue');
INSERT INTO edutestdata VALUES(3, -100, 300, 0.5, 0.5, 'blue');
INSERT INTO edutestdata VALUES(4, 100, -300, 0.5, 0.5, 'blue');
INSERT INTO edutestdata VALUES(1, 1, 2, 3.0, 4.0, 'yellow');
INSERT INTO edutestdata VALUES(2, 100, 300, 0.5, 0.5, 'yellow');
INSERT INTO edutestdata VALUES(3, -100, 300, 0.5, 0.5, 'yellow');
INSERT INTO edutestdata VALUES(4, 100, -300, 0.5, 0.5, 'yellow');