17.05 - Example: SELECT and the Function Mapping Definition - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

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 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;