EXECUTE FUNCTION Examples - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantageā„¢

Example: EXECUTE FUNCTION with INPUT_FMT

EXECUTE FUNCTION
INTO VOLATILE ART(tmpTable)
TD_MATRIXMULTIPLY(
    MATRIX_SPEC(
        TABLE_NAME(m1),
        ROW_AXIS(SEQUENCE(r)),
        COLUMN_AXIS(SEQUENCE(c)),
        MATRIX_ID(id),
        PAYLOAD( FIELDS(v),CONTENT(REAL))
    ),
    MATRIX_SPEC(
        TABLE_NAME(m2),
        ROW_AXIS(SEQUENCE(r)),
        COLUMN_AXIS(SEQUENCE(c)),
        MATRIX_ID(id),
        PAYLOAD( FIELDS(v),CONTENT(REAL))
    ) where id = 1,
    INPUT_FMT(INPUT_MODE(MANY2ONE))
);

Example: Auto-correction and Auto-covariance

EXECUTE FUNCTION INTO VOLATILE ART(ACF_RESULTS)
TD_ACF(
   SERIES_SPEC( 
      TABLE_NAME(OCEAN_BUOYS), 
      ROW_AXIS(TIMECODE(TD_TIMECODE)), 
      SERIES_ID(Ocean_Name,BuoyID),
      PAYLOAD(FIELDS(JsonCol.Measure.Salinity), CONTENT(REAL))
   ),
   FUNC_PARAMS(
      MAXLAGS(2500), 
      FUNC_TYPE(0), 
      UNBIASED(0), 
      DEMEAN(1), 
      QSTAT(1), 
      ALPHA(1)
   )
);

Example: Map Plot

EXECUTE FUNCTION
TD_Plot
(
    SERIES_SPEC
   ( 
      TABLE_NAME(ACFDemo),
      ROW_AXIS(SEQUENCE(ROW_I)),
      SERIES_ID(BuoyID),
      PAYLOAD 
     (FIELDS 
        (Magnitude, CONF_OFF_Magnitude),CONTENT(MULTIVAR_REAL) 
     )
   ) 
   WHERE BuoyID IN (8),
   FUNC_PARAMS
   ( 
      PLOTS[(TYPE('corr') ,LEGEND('best'))],
      IMAGE('png')
    )
);

Example: Linear Regression

EXECUTE FUNCTION INTO VOLATILE ART(LR_RESULTS)
TD_LINEAR_REGR(
   SERIES_SPEC(
      TABLE_NAME(HOUSE_VALUES), 
      SERIES_ID(CITYID), 
      ROW_AXIS(TIMECODE(TD_TIMECODE)
   ),
   PAYLOAD(FIELDS(HOUSE_VAL, SALARY),CONTENT(MULTIVAR_REAL))) WHERE CITYID=33,
   FUNC_PARAMS(
      FORMULA('Y = B0 + B1*X1'), 
      WEIGHTS(0),
      ALGORITHM('QR'), 
      COEFF_STATS(1),
      VARIABLES_COUNT(2), 
      MODEL_STATS(1), 
      RESIDUALS(1)) 
);