StringSimilarity Function Example | Teradata Vantage - StringSimilarity with Specified Column Names - Analytics Database

Database Analytic Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-04-01
dita:mapPath
gjn1627595495337.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
jmh1512506877710
Product Category
Teradata Vantageā„¢

StringSimilarity Input

id src_text1 src_text2 tar_text
1 astre astter aster
2 hone fone phone
3 acquiese acquire acquiesce
4 AAAACCCCCGGGGA CCCGGGAACCAACC CCAGGGAAACCCAC
5 alice allen allies
6 angela angle angels
7 senter center centre
8 chef cheap chief
9 circus circle circuit
10 debt debut debris
11 deal dell lead
12 bare bear bear

StringSimilarity SQL Call with Specified Column Names

SELECT * FROM StringSimilarity (
  ON strsimilarity_input PARTITION BY ANY
  USING
  ComparisonColumnPairs ('jaro (src_text1, tar_text) AS jaro1_sim',
                         'LD (src_text1, tar_text) AS ld1_sim',
                         'n_gram (src_text1, tar_text, 2) AS ngram1_sim',
                         'jaro_winkler (src_text1, tar_text, 0.1) AS jw1_sim'
  )
  CaseSensitive ('true')
  Accumulate ('id', 'src_text1', 'tar_text')
) AS dt ORDER BY id;

StringSimilarity Output with Specified Column Names

Columns 1-3
id src_text1 tar_text
1 astre aster
2 hone phone
3 acquiese acquiesce
4 AAAACCCCCGGGGA CCAGGGAAACCCAC
5 alice allies
6 angela angels
7 senter center
8 chef chief
9 circus circuit
10 debt debris
11 deal lead
12 bare bear
Columns 4-7
jaro1_sim ld1_sim ngram1_sim jw1_sim
0.933333333333333 0.6 0.5 0.953333333333333
0.933333333333333 0.8 0.75 0.933333333333333
0.925925925925926 0.777777777777778 0.5 0.948148148148148
0.824175824175824 0.214285714285714 0.384615384615385 0.824175824175824
0.822222222222222 0.5 0.4 0.857777777777778
0.888888888888889 0.833333333333333 0.8 0.933333333333333
0.822222222222222 0.5 0.4 0.822222222222222
0.933333333333333 0.8 0.5 0.946666666666667
0.849206349206349 0.714285714285714 0.666666666666667 0.90952380952381
0.75 0.5 0.4 0.825
0.666666666666667 0.5 0.333333333333333 0.666666666666667
0.833333333333333 0.5 0.333333333333333 0.85