TD_StrApply Example | strapply | Teradata Vantage - Example: How to Use TD_StrApply - Analytics Database

Database Analytic Functions

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

Every complete example in this document is available in a zip file that you can download. The zip file includes a SQL script file that creates the input tables for the examples. If you are reading this document on https://docs.teradata.com/, you can download the zip file from the attachment in the left sidebar.

TD_StrApply Input Table: input_table

passenger survived pclass name                                                gender age sibsp parch ticket            fare         cabin embarked 
--------- -------- ------ ----                                                ------ --- ----- ----- ------            ----         ----- -------- 
        5        0      3 Allen; Mr. William Henry                            male    35     0     0  373450            8.050000000 null  S       
        4        1      1 Futrelle; Mrs. Jacques Heath (Lily May Peel)        female  35     1     0  113803           53.100000000 C123  S       
        3        1      3 Heikkinen; Miss. Laina                              female  26     0     0  STON/O2. 3101282  7.925000000 null  S       
        1        0      3 Braund; Mr. Owen Harris                             male    22     1     0  A/5 21171         7.250000000 null  S       
        2        1      1 Cumings; Mrs. John Bradley (Florence Briggs Thayer) female  38     1     0  PC 17599         71.283300000 C85   C       

Example: TD_StrApply SQL Call

SELECT * FROM TD_strApply ( 
ON strApply_input_table as InputTable PARTITION BY ANY
USING   
TargetColumns ('Gender')
stringOperation ('toUpper') 
Accumulate('Passenger')
InPlace('True')
) as dt order by 1;

TD_StrApply Output

passenger  gender    
---------  ------ 
        1  MALE  
        2  FEMALE
        3  FEMALE
        4  FEMALE
        5  MALE