TD_RESAMPLE Function Examples | Teradata Vantage - TD_RESAMPLE Examples - Teradata Vantage

Database Unbounded Array Framework Time Series Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
ncd1634149624743.ditamap
dita:ditavalPath
ruu1634160136230.ditaval
dita:id
ncd1634149624743

TD_RESAMPLE Input Table ProductionData

TD_Timecode TD_Seq ProductID BEER_SALES WINE_SALES
2022-02-28 16:25:01 17 33 57.90 104.00
2022-02-28 15:45:02 16 33 65.30 152.00
2022-02-28 14:15:03 15 33 84.80 130.00
2022-02-28 12:30:04 14 33 91.60 105.00
2022-02-28 13:10:01 13 33 83.20 132.00
2022-02-28 12:45:02 12 33 102.00 152.00
2022-02-28 12:00:03 11 33 92.70 111.00
... ... ... ... ...

Example: TD_RESAMPLE Call with Linear Interpolation

EXECUTE FUNCTION INTO VOLATILE ART(ResampledSeries)
TD_RESAMPLE(
   SERIES_SPEC(
       TABLE_NAME(ProductionData),
       ROW_AXIS(TIMECODE(MYTIMECODE)),
       SERIES_ID(ProductID,
       PAYLOAD(FIELDS(BEER_SALES),CONTENT(REAL))
   ),
   FUNC_PARAMS(
       TIMECODE(
            START_VALUE(TIMESTAMP '2022-02-28 00:00:00'),
            DURATION(CAL_DAYS(1))
        ),
       INTERPOLATE(LINEAR)
   ),
   OUTPUT_FMT(INDEX_STYLE(NUMERICAL_SEQUENCE))
);

TD_RESAMPLE Output for Linear Interpolation

PRODUCTID ROW_I BEER_SALES
33         0     6.000
33         1     6.900
33         2     7.669
33         3     7.138
33         4     7.600
33         5     7.507
33         6     7.461
33         7     7.653
33         8     7.407
...

Example: TD_RESAMPLE Call with SEQUENCE and Spline Interpolation

EXECUTE FUNCTION INTO VOLATILE ART(resample_art)
TD_RESAMPLE
(
    SERIES_SPEC(
        TABLE_NAME(ProductionData),
        SERIES_ID(BuoyID),
        ROW_AXIS(SEQUENCE(TD_SEQ)),
        PAYLOAD(
            FIELDS(WINE_SALES),
            CONTENT(REAL)
        )
    ),
    FUNC_PARAMS(
        SEQUENCE(
            START_VALUE(0), 
            DURATION(1)
        ),
        INTERPOLATE(SPLINE)
        SPLINE_PARAMS(
            METHOD(CLAMPED),
            YP1(1.2),
            YP2(5.2)
         )
    ),
    OUTPUT_FMT(INDEX_STYLE(NUMERICAL_SEQUENCE))
);

TD_RESAMPLE Output for SEQUENCE and Spline Interpolation

ProductID      ROW_I      WINE_SALES
33             0          111.7
33             1          111.7
33             2          122.2
33             3          112.8
33             4          92.0790
33             5          100.9
33             6          131.4
33             7          126.2
33             8          161.7
....