Creating, Installing, and Invoking a Stream Function - Aster Execution Engine

Teradata Aster® Developer Guide

Product
Aster Execution Engine
Release Number
7.00.02
Published
July 2017
Language
English (United States)
Last Update
2018-04-13
dita:mapPath
xnl1494366523182.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
ffu1489104705746
lifecycle
previous
Product Category
Software
  1. Write your script in the language of your choice.

    To write the function, write a script or program that reads rows from its input stream (stdin) and writes rows to its output stream (stdout).

    In the output, your program must delimit each row with a newline (\n) character and delimit each column with the character expected by your queries (read the description of the DELIMITER clause for an explanation). By default, the column delimiter is a tab (\t) character.

  2. Ensure that the script exits with exit(0) after a successful execution.
  3. Run ACT and connect to your Aster instance:
    $ act -U beehive -h IP_address_of_queen
  4. Install your script as a file in the Aster instance.

    To do this, use the \install command at the ACT SQL prompt. (See Manage Functions and Files in an Aster Instance for more details.)

    For example, to install the mapper.py Python script, enter this command:

    beehive=> \install mapper.py;
    The script, mapper.py, is a sample shown in Running a Python Script.
  5. [Optional] Use the \install command to install any other file needed by your script.
  6. To invoke a Stream function, enter the SQL-MapReduce query that calls the STREAM API.

    For example:

    beehive=> SELECT * FROM STREAM
    beehive->(ON (SELECT content FROM input_table)
    beehive->SCRIPT ('python mapper.py')
    beehive->OUTPUTS ('word varchar', 'count int'));