17.05 - Example: Function Processing with Nested Variables - 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)

The function mapping definition user_SparseSVMTrainer for the function SparseSVMTrainer includes nested parameters:

Var1(old_var1),
var2(old_var2||'_'|| var3),
old_var1(var3)
CREATE FUNCTION MAPPING user_SparseSVMTrainer
FOR SparseSVMTrainer SERVER coprocessor
Using
ANY   IN TABLE,
inputtable IN TABLE,
ModelTable,
IDColumn,
AttributeColumn,
LabelColumn ('species') ,
Valuecolumn(var2 || '_' || var1) ,
MaxStep (var1) ,
Seed ('0'),
var1(old_var1),
var2(old_var2||'_'|| var3),
old_var1(var3),
var3(10)
;

This SELECT statement specifies values for var3 and old_var2.

SELECT * FROM user_SparseSVMTrainer (
ON svm_iris_input_train as InputTable PARTITION BY 1
USING
ModelTable ('svm_iris_model')
LabelColumn ('species')
MaxStep (10)
Seed ('1')
var3 (2)
old_var2('sample')
IDColumn('id')
AttributeColumn('attribute')
) as dt1;

The query is rewritten as follows. var2 resolves to sample_2 based on the concatenated expression of old_var2 and var3. The mapping definition substitutes var1 for old_var1. old_var1 is substituted for var3, which is specified as 2 in the query. The concatenated expression defined for ValueColumn resolves to sample_2_2.

SELECT * FROM user_SparseSVMTrainer (
ON svm_iris_input_train as InputTable PARTITION BY 1
USING
ModelTable ('svm_iris_model')
LabelColumn ('species')
Valuecolumn('sample_2_2')
MaxStep (10)
Seed ('1')
IDColumn('id')
AttributeColumn('attribute')
) as dt1;

This SELECT statement specifies values for var1 and var2.

SELECT * FROM user_SparseSVMTrainer (
ON svm_iris_input_train as InputTable PARTITION BY 1
USING
ModelTable ('svm_iris_model')
LabelColumn ('species')
IDColumn('id')
AttributeColumn('attribute')
Seed ('1')
var1 (2)
var2('sample')
) as dt1;

The query is rewritten as follows. The function mapping defines ValueColumn as the concatenation of var1 var2. MaxStep is substituted for var1.

SELECT * FROM user_SparseSVMTrainer (
ON svm_iris_input_train as InputTable PARTITION BY 1
USING
ModelTable ('svm_iris_model')
IDColumn('id')
AttributeColumn('attribute')
LabelColumn ('species')
Valuecolumn('sample_2')
MaxStep (2)
Seed ('1')
) as dt1;

This SELECT statement specifies values for old_var1 and var2.

SELECT * FROM user_SparseSVMTrainer (
ON svm_iris_input_train as InputTable PARTITION BY 1
USING
ModelTable ('svm_iris_model')
LabelColumn ('species')
IDColumn('id')
AttributeColumn('attribute')
Seed ('1')
old_var1 (2)
var2('sample')
) as dt1;

The query is rewritten as follows. Per the function mapping definition, var1 is substituted for old_var1 with a value of 2. The ValueColumn concatenated expression resolves to sample_2. MaxStep is substituted for var1 with a value of 2.

SELECT * FROM user_SparseSVMTrainer (
ON svm_iris_input_train as InputTable PARTITION BY 1
USING
ModelTable ('svm_iris_model')
LabelColumn ('species')
IDColumn('id')
AttributeColumn('attribute')
Valuecolumn('sample_2')
MaxStep (2)
Seed ('1')
) as dt1;