Examples: Function Processing with Default Values for Variables - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530

The function mapping definition usr_AllPairsShortestPath for the function AllPairsShortestPath includes a concatenated expression for the variable TargetKey and default values for EdgeWeight and Distance.

CREATE FUNCTION MAPPING usr_AllPairsShortestPath
FOR AllPairsShortestPath SERVER TD_SERVER_DB.coprocessor
USING
vertices(vertex) IN TABLE ,
edges(edge) IN TABLE ,
sources(source) IN TABLE ,
targets(trgt) IN TABLE ,
TargetKey(GroupColumn||'_'||Distance) ,
EdgeWeight('calls') ,
MaxDistance(Distance) , Distance(1),
Directed ,GroupSize ,SequenceInputBy;

The SELECT statement specifies a value for the variable GroupColumn.

SELECT * FROM usr_AllPairsShortestPath (
ON callers AS vertices PARTITION BY callerid
ON calls AS edges PARTITION BY callerfrom
USING
GroupColumn('tabl')
) as dt ORDER BY source, target;

On submittal, the query is rewritten as follows. TargetKey is included because the mapping definition provides a default value for Distance and the query provides a value for GroupColumn to resolve the concatenated variable expression.

Per the mapping definition, MaxDistance is substituted for Distance. EdgeWeight is included because the mapping definition provides a default value.

SELECT * FROM AllPairsShortestPath (
ON callers AS vertices PARTITION BY callerid
ON calls AS edges PARTITION BY callerfrom
USING
TargetKey('tabl_1')
MaxDistance('1')
EdgeWeight('calls')
) as dt ORDER BY source, target;