Example: SELECT and the Function Mapping Definition - Teradata Database - Teradata Vantage NewSQL Engine

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

In a SELECT statement with a function mapping, each correlation_name, USING custom clause parameter, or OUT TABLE name that you specify must correspond to a correlation_name, USING custom clause parameter, or OUT TABLE name in the function mapping definition. For information on how to create a function mapping, see "CREATE FUNCTION MAPPING" in Teradata Vantage™ SQL Data Definition Language Syntax and Examples, B035-1144.

Below is the function mapping definition coxph for the function coxph on the server coprocessor.

CREATE FUNCTION MAPPING appl_view_db.coxph
FOR coxph SERVER coprocessor 
MAP JSON ( '{ "function_version": "1.0" }') 
   	USING
     	   InputTable IN TABLE,
         CoefficientTable OUT TABLE,
         LinearPredictorTable OUT TABLE,
         TimeIntervalColumn, EventColumn, Threshold, MaxInterNum,
	   FeatureColumns;

In the SELECT statement below, each correlation_name, USING custom clause parameter, or OUT TABLE name corresponds to a correlation_name, USING custom clause parameter, or OUT TABLE name in the function mapping definition.

SELECT * FROM appl_view_db.coxph (
        ON appl_view_db.input_table AS inputtable PARTITION BY 1
        OUTPUT TABLE CoefficientTable(coefficient_table)
        OUTPUT TABLE LinearPredictorTable(linearpredictor_table)
        USING
          FeatureColumns('c1','c2')
          TimeIntervalColumn('t1')
          EventColumn('e1')
) AS dt;